Saturday, 17 August 2013

Move Data from Select-Options to Internal Table

  TABLES : mara.

TYPES : BEGIN OF ty_mat,
  matnr TYPE matnr,
  END OF ty_mat.
data : gw_mat type ty_mat.
SELECT-OPTIONS : mat FOR mara-matnr.


DATA : itab TYPE STANDARD TABLE OF mara.
DATA : it TYPE STANDARD TABLE OF matnr.

*MOVE mat[] TO it[] .

LOOP AT mat INTO gw_mat.

APPEND gw_mat+2 to it.
* Here we have added +2(offset) because every time IE or IEQ gets added. To remove this character we need to keep +2 or +3. if hte value is getting truncation in internal table IT, then increase the lenght of field in internaltable IT




CLEAR gw_mat.

ENDLOOP.

SELECT * FROM mara INTO TABLE itab WHERE matnr IN mat.



CLEAR : mat[].

mat[] = it[] .


WRITE : 'bharat' .

Sunday, 28 July 2013

Finding Funtion Group

We can find all FunctionGroup as below.

Goto Se11
Enter Table  TADIR
In table selection screen enter  OBJECT = FUGR, then you will get all the function groups.
If you want function groups created by a person , enter author name  in addition to OBJECT = FUGR

Standard Program to Delete Scheduled Jobs is RSBTCDEL

Standard Program to Delete Scheduled Jobs is RSBTCDEL.

Run this program in SE38, here you can delete all the jobs

Saturday, 22 June 2013

Using Perform of one program in Another program

Example :

  PERFORM f_add_ser_cond IN PROGRAM znm_sc_r_qn_erro_disp IF FOUND
                            TABLES    i_cond2
                                      t_serialno
                                      lt_sernr
                            USING     matnr
                                      vwerk
                                      aufart
                                      repos
                             CHANGING lv_flag.

Tuesday, 18 June 2013

User Exit Table MODSAP

1. MODSAP is the table which has Exit name .
2. When you have a include of an exit, use the where used list and find the EXIT name.
3. Pass the Exit name to the MODSAP , then you can find the Enhancement name.

Wednesday, 12 June 2013

Disable Fields in Selection Screen of Report Program based on Authority Check.

1.  First check for Required condition ( Checking authorization in  current example) in INITIALIZATION . Based on condition use LOOP AT SCREEN to disable or make the field invisible.

Example       
  INITIALIZATION.
gv_readonly_flag = 'X' .
 LOOP AT SCREEN.

      IF screen-name EQ 'P_R1'.
        break mavb.
        screen-invisible = '1'.
        screen-active = '0' .
        MODIFY SCREEN.
      ENDIF.

    ENDLOOP.



2. Keep a flag when you run the above code and copy the same code in  AT SELECTION-SCREEN OUTPUT.  as initially the field will be invisible in the selection screen but when the user press ENTER, the field will become visible as INITIALIZATION will be executed only once in the life of program, so when the user press enter the field will become visible. So we have to write the same code in  AT SELECTION-SCREEN OUTPUT.
Example

  AT SELECTION-SCREEN OUTPUT.
  IF gv_readonly_flag = 'X' .
    LOOP AT SCREEN.

      IF screen-name EQ 'P_R1'.
        break mavb.
        screen-invisible = '1'.
        screen-active = '0' .
        MODIFY SCREEN.
      ENDIF.

    ENDLOOP.

  ENDIF.



Example with a scenario for Authorisation check :

  SELECTION-SCREEN  BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS : p_r1  RADIOBUTTON GROUP g1 ,
             p_r2  RADIOBUTTON GROUP g1 .

SELECTION-SCREEN END OF BLOCK b2.



  INITIALIZATION.

  CALL FUNCTION 'AUTHORITY_CHECK'
    EXPORTING
      user                = sy-uname
      object              = 'ZQMCERTMGR'
      field1              = 'ZQMCRTACVT'
      value1              = '01'
    EXCEPTIONS
      user_dont_exist     = 1
      user_is_authorized  = 2
      user_not_authorized = 3
      user_is_locked      = 4
      OTHERS              = 5.

  IF sy-subrc NE 2.

    CALL FUNCTION 'AUTHORITY_CHECK'
      EXPORTING
        user                = sy-uname
        object              = 'ZQMCERTMGR'
        field1              = 'ZQMCRTACVT'
        value1              = '03'
      EXCEPTIONS
        user_dont_exist     = 1
        user_is_authorized  = 2
        user_not_authorized = 3
        user_is_locked      = 4
        OTHERS              = 5.
    IF sy-subrc EQ 2 .
      gv_readonly_flag = 'X' .
    ELSEIF sy-subrc NE 0 .
      MESSAGE 'User is not Authorised'(019) TYPE 'E' .
      LEAVE TO LIST-PROCESSING.
      EXIT.
    ENDIF.
  ENDIF.

  IF gv_readonly_flag = 'X' .

    LOOP AT SCREEN.

      IF screen-name EQ 'P_R1'.
        break mavb.
        screen-invisible = '1'.
        screen-active = '0' .
        MODIFY SCREEN.
      ENDIF.

    ENDLOOP.

  ENDIF.

AT SELECTION-SCREEN OUTPUT.
  IF gv_readonly_flag = 'X' .
    LOOP AT SCREEN.

      IF screen-name EQ 'P_R1'.
        break mavb.
        screen-invisible = '1'.
        screen-active = '0' .
        MODIFY SCREEN.
      ENDIF.

    ENDLOOP.

  ENDIF.



Explanation : P_R1 and P_R2 are radion buttons. P_R1 is for write access and P_R2 is for read only report. So when we check for authorisation using the Authority_check function module, if user has authorisation for write access, authority FM with field value '01' will pass, if the user doesn't have write access , then we check for read access.If user has read access then we make the radio button P_R1 invisible as per above code.