Search This Blog

Showing posts with label SAP REPORTS. Show all posts
Showing posts with label SAP REPORTS. Show all posts

Tuesday, March 23, 2021

Loop Control Statements in SAP ABAP

 Loop Control Statements in SAP ABAP


CONTINUE :  Immediately skip the  rest of the code within the loop and start the loop for the next value.


CHECK :  If condition is false. Start the loop for the next value.


EXIT :  Terminates the loop entirely and transfers execution to the statement immediately following the loop.

Monday, February 22, 2021

Adding functions in CL_SALV_TABLE

 

DATAlo_functions TYPE REF TO cl_salv_functions_list.


  lo_functions = lo_alv->get_functions( ).

For default functions
  lo_functions->set_default( abap_true ).




For all functions

  lo_functions->set_all( abap_true ).

Friday, February 19, 2021

Assign a T-Code to a QuickViewer query (SQVI)

 Assign a T-Code to a QuickViewer query (SQVI)

1.      Go to SQVI t code and enter your query name and press enter.

2.      In the menu path select Quick view–> additional functions–>Generate Program



3.      After Generating the program In the menu path select Quick view–> additional functions–>Display report Name

 

 

4.          Now in se38 enter the report name in Program field and execute

 

5.          You will get the Initial Selection screen of the report . Go to Menu of System –>Status

6.          Note down the Program name


7.          Go to SE93 and Create a Z tcode for the query, Enter the description and importantly you have to     select the 2nd Option radio Button Program and Selection Screen (Report Transaction) and Press enter

8.          In the next screen enter the Report name In Program field and enter the screen number

9.          In the classification Section select Professional user Transaction

10       In GUI support section select all the options i.e SAPGUI for HTML,Java,Windows


Thursday, February 18, 2021

Program to find T-Code Roles org. level against SAP User

 

Program to find T-Code Roles org. level against SAP User.

This program is basically for the basis guys who want all the information of a user on one click.

SAP User -> T-Code -> SAP Roles -> Org. level


Table used:

AGR_USERS - Assignment of roles to users

AGR_1252 - Organizational elements for authorizations

AGR_1251 - Authorization data for the activity group


REPORT ztest.

  PARAMETERS user TYPE agr_users-uname DEFAULT 'RAHUL_ABAP'.

  TYPES BEGIN OF ty_final,
            tcode TYPE tcode,              " tcode
            uname TYPE agr_users-uname,  " user name
            role  TYPE agr_name,          " ROLE
            varbl TYPE agr_1252-varbl,   "  org level
          END OF ty_final.

  DATAit_final TYPE TABLE OF ty_final,
        wa_final TYPE ty_final.
  DATAit_fieldcat TYPE slis_t_fieldcat_alv,
        wa_fcat     TYPE slis_fieldcat_alv.

  START-OF-SELECTION.

    PERFORM fetch_data.
    PERFORM display_data.

*&---------------------------------------------------------------------*
*& Form FETCH_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
  FORM fetch_data .
    SELECT agr_name" role
           uname
           FROM agr_users INTO TABLE @DATA(t_userWHERE uname @user.  " for all role

    SELECT agr_name,
           varbl
           FROM agr_1252 INTO TABLE @DATA(t_agrFOR ALL ENTRIES IN @t_user WHERE agr_name @t_user-agr_name.  " for all org level agains role
    SORT t_agr BY agr_name.

   SELECT agr_name,
           low
          FROM AGR_1251 INTO TABLE @DATA(t_tcodeFOR ALL ENTRIES IN @t_user WHERE agr_name =  @t_user-agr_name AND OBJECT 'S_TCODE'.

   LOOP AT t_tcode INTO DATA(w_tcode.

      wa_final-tcode w_tcode-low.
      wa_final-uname =  user.
      LOOP AT t_agr INTO DATA(w_agrWHERE agr_name w_tcode-agr_name.
        wa_final-role w_agr-agr_name.
        wa_final-varbl w_agr-varbl.

        APPEND wa_final TO it_final.
        CLEARw_agrwa_final.
      ENDLOOP.

     CLEAR w_tcode.
    ENDLOOP.

  ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
  FORM display_data .
    PERFORM create_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
*       I_INTERFACE_CHECK  = ' '
*       I_BYPASSING_BUFFER = ' '
*       I_BUFFER_ACTIVE    = ' '
        i_callback_program sy-repid
*       I_CALLBACK_PF_STATUS_SET          = ' '
*       I_CALLBACK_USER_COMMAND           = 'INT_ALV1'
        it_fieldcat        it_fieldcat
*       IT_EXCLUDING       =
*       IT_SPECIAL_GROUPS  =
*       IT_SORT            =
*       IT_FILTER          =
*       IS_SEL_HIDE        =
        i_default          'X'
        i_save             'I'
      TABLES
        t_outtab           it_final[]
      EXCEPTIONS
        program_error      1
        OTHERS             2.
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_FIELDCAT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
  FORM create_fieldcat .

    wa_fcat-fieldname 'UNAME'.
    wa_fcat-tabname 'IT_FINAL'.
    wa_fcat-seltext_m 'USER NAME'.
    wa_fcat-outputlen '20'.
    APPEND wa_fcat TO it_fieldcat.
    CLEAR wa_fcat.

    wa_fcat-fieldname 'TCODE'.
    wa_fcat-tabname 'IT_FINAL'.
    wa_fcat-seltext_m 'T-CODE'.
    wa_fcat-outputlen '20'.
    APPEND wa_fcat TO it_fieldcat.
    CLEAR wa_fcat.

    wa_fcat-fieldname 'ROLE'.
    wa_fcat-tabname 'IT_FINAL'.
    wa_fcat-seltext_m 'ROLE.'.
    wa_fcat-outputlen '30'.
    APPEND wa_fcat TO it_fieldcat.
    CLEAR wa_fcat.

    wa_fcat-fieldname 'VARBL'.
    wa_fcat-tabname 'IT_FINAL'.
    wa_fcat-seltext_m 'ORG. LEVEL'.
    wa_fcat-outputlen '30'.
    APPEND wa_fcat TO it_fieldcat.
    CLEAR wa_fcat.

  ENDFORM.

Pages