Search This Blog

Showing posts with label abap. Show all posts
Showing posts with label abap. Show all posts

Thursday, March 11, 2021

BY-PASS AUTHORIZATION/ LINE IN DEBUG MODE

 


BY-PASS AUTHORIZATION/ LINE IN DEBUG MODE

The Magic of SHIFT + F12

To bypass any authorization, sy-subrc or any specific line you dont want to execute .

Just put your cursor on the desired line and then press the SHIFT + F12 key.


SHIFT + F12 key

Wednesday, March 3, 2021

Create SQVI query in SAP

 Create SQVI query in SAP

Step 1.  Goto T-Code - SQVI.  Provide Name for the query ( EX. ZMAT ) . 
              Click on data source and select table join.
                





Step 2.  Next screen is your navigation window. Here you can set relationship between tables.







Step 3.  Press SHIFT + F1 or  select insert table option and provide name of the tables
              you want to join.






Step 4. After set relationship click on back button and  below screen will appear.
            Here you can set field to be displayed when query execute.


Step 5. In next tab you can set sorting order for the query to be displayed.





Step 6.  In selection field tab select the fields whom you want to display on selection screen.
              Data will be fetch on that  field.





Step 7.  ALL SET. NOW EXECUTE AND PROVIDE VALUE FOR SELECTION SCREEN.





ASSIGN T-CODE TO SAP QUERY 


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


Monday, February 15, 2021

Difference between workbench and customized request?

Difference between workbench and customized request?

Both the Customizing and Workbench Requests are part of the change transporting mechanism in SAP. This means that the changes are moved to the next systems in the landscape using the transport requests.

Changes as part of the Technical activities are saved in the Workbench Request => WRICEF Development components.

Changes as part of the Functional Configuration are saved in the Customizing Request (because the functional consultant configures the SAP System as per the client’s requirements).

T-Codes for TR - SE01, SE09, SE10.

 

Difference between workbench and customized:





Customizing Requests:

 Change of customizing settings are recorded in “Customizing Requests”.

Customizing requests contain changes to “Client Depending Tables”.

When we release the requests, the current status of the recorded settings are
exported and can be transport to other SAP systems.

When we create a customizing request, the transport target system automatically
assigned by the transport layer configuration of SAP STMS system.

 

Workbench Requests:

 If going to change “ABAP workbench objects” then “Workbench Requests” recorded

by the SAP system.

Workbench requests contain changes to “Client Independent Tables” and related to the
Development tasks.

There are two type of workbench requests, one of is LOCAL and the other one is “TRANSPORTABLE”



Concatenation in ABAP

Concatenation in ABAP is done by joining two string together.

Following program has implemented the same:



  REPORT ztest.
  PARAMETERSlv_data1 TYPE string"VALUE 'Mr.'
              lv_data2 TYPE string"VALUE 'India'
  DATA:    lv_data TYPE string.
  CONCATENATE lv_data1 lv_data2 INTO lv_data SEPARATED BY space.
  WRITElv_data"Output is 'Mr. India"

Events in Report

 

Classical Reports have following events, these events are common for Interactive Reports:

  • LOAD-OF-PROGRAM : First event fired, loads program in memory
  • INITIALIZATION: Initialize variable
  • START-OF-SELECTION : Actual Business Logic (After START-OF-SELECTION)
  • END-OF-SELECTION : To end above
  • AT SELECTION-SCREEN : To validate Multiple Input fields (After Initialization and before START-OF-SELECTION) (After
  • AT SELECTION-SCREEN OUTPUT: To manipulate Dynamic screen
  • AT SELECTION-SCREEN ON
  • AT SELECTION-SCREEN ON END OF
  • AT SELECTION-SCREEN ON BLOCK
  • AT SELECTION-SCREEN ON RADIOBUTTON GROUP
  • AT SELECTION-SCREEN ON VALUE REQUEST
  • TOP-OF-PAGE : To print heading
  • END-OF-PAGE: To print footer

Events of Interactive Report in SAP ABAP:

  • TOP-OF-PAGE
  • END-OF-PAGE
  • AT-LINE-SELECTION
  • AT USER-COMMAND
  • AT PFnn
  • SET USER-COMMAND


Sample Program : 


  REPORT ZEVENTS.

  TABLESmara.
  TYPE-POOLSslis.

  TYPESBEGIN OF ty_mara,
           matnr TYPE mara-matnr,
           ersda TYPE mara-ersda,   " CREATED ON
           mtart TYPE mara-mtart,   " MATERIAL TYPE
         END OF ty_mara.

  DATAitab TYPE TABLE OF ty_mara,
        wa   TYPE ty_mara.
  DATAit_makt TYPE TABLE OF makt.
  " FIELDCATALOG DECLARATION

*  types: slis_t_fieldcat_alv type slis_fieldcat_alv occurs 1.

*    "SLIS_T_FIELDCAT_ALV" IS A TABLE TYPE WITH STRUCTURE  TYPE "SLIS_FIELDCAT_ALV"

  DATAit_fieldcat TYPE  slis_t_fieldcat_alv,

        wa_fieldcat TYPE slis_fieldcat_alv.



  "****************************** AT SELECTION SCREEN   ******************************

  SELECTION-SCREENBEGIN OF BLOCK b1 WITH FRAME TITLE header.

  PARAMETERSr1 RADIOBUTTON GROUP g1 USER-COMMAND u1" FOR ALV
  PARAMETERSp_mara TYPE mara-matnr MODIF ID abc.

  PARAMETERSr2 RADIOBUTTON GROUP g1 .                  " FOR CLASSICAL
  PARAMETERSp_mtart TYPE mara-mtart MODIF ID xyz.

  SELECTION-SCREENEND OF BLOCK b1.


  "****************************** INITIALIZATION ******************************

  INITIALIZATION.

    header 'SELECTION CRITERIA'.

    p_mara '000000000000000001'.
    p_mtart 'VERP'.

    "****************************** AT SELECTION SCREEN - OUTPUT ******************************

  AT SELECTION-SCREEN OUTPUT.

    LOOP AT SCREEN.
      IF screen-group1 'ABC'.
        IF r2 'X'.
          screen-active 0.

        ELSE.
          screen-active '1'.

        ENDIF.
*             MODIFY SCREEN.
      ENDIF.


      IF screen-group1 'XYZ'.
        IF r1 'X'.
          screen-active 0.
        ELSE.
          screen-active '1'.
        ENDIF.
*             MODIFY SCREEN.
      ENDIF.
      MODIFY SCREEN.
    ENDLOOP.


    "****************************** AT SELECTION SCREEN ******************************


  AT SELECTION-SCREEN.  " FOR WHOLE SELECTION SCREEN VALIDATION
    SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr p_mara OR mtart p_mtart.

    IF sy-subrc NE 0.

      MESSAGE'NOT FOUND' TYPE 'I' DISPLAY LIKE 'I' .

    ENDIF.


*  ***************************** AT SELECTION SCREEN - ON FIELD ******************************


  AT SELECTION-SCREEN ON p_mtart.  " FOR ONLY ON REQUIRED FIELD VALIDATON
    SELECT SINGLE mtart FROM t134 INTO mara-mtart WHERE mtart p_mtart.

    IF sy-subrc NE 0.

      MESSAGE'NOT FOUND' TYPE 'E' DISPLAY LIKE 'I'.

    ENDIF.

*  ***************************** AT SELECTION SCREEN - ON VALUE REQUEST ******************************


  AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_mara.

    TYPESBEGIN OF ty_str,

             matnr TYPE mara-matnr,
             ersda TYPE mara-ersda,

           END OF ty_str.

    DATAitab1 TYPE TABLE OF ty_str.


    SELECT matnr ersda FROM mara INTO TABLE itab1 UP TO 10 ROWS.


    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
*       DDIC_STRUCTURE  = ' '
        retfield        'P_MARA'
*       PVALKEY         = ' '
        dynpprog        sy-repid
        dynpnr          '1000'
        dynprofield     'P_MARA'
*       STEPL           = 0
*       WINDOW_TITLE    =
*       VALUE           = ' '
        value_org       'S'
*       MULTIPLE_CHOICE = ' '
*       DISPLAY         = ' '
*       CALLBACK_PROGRAM       = ' '
*       CALLBACK_FORM   = ' '
*       MARK_TAB        =
*     IMPORTING
*       USER_RESET      =
      TABLES
        value_tab       itab1[]
*       FIELD_TAB       =
*       RETURN_TAB      =
*       DYNPFLD_MAPPING =
      EXCEPTIONS
        parameter_error 1
        no_values_found 2
        OTHERS          3.
    IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.



    "****************************** START OF SELECTION ******************************

  START-OF-SELECTION.





    PERFORMget_data.
    PERFORMdisplay_data.
*  &---------------------------------------------------------------------*
*  &      Form  GET_DATA
*  &---------------------------------------------------------------------*
*         text
*  ----------------------------------------------------------------------*
*    -->  p1        text
*    <--  p2        text
*  ----------------------------------------------------------------------*
  FORM get_data .

    IF r1 'X'.
      SELECT matnr
      ersda
      mtart FROM mara INTO TABLE itab WHERE matnr p_mara .

    ELSEIF r2 'X'.

      SELECT matnr
      ersda
      mtart FROM mara INTO TABLE itab WHERE mtart p_mtart .
    ENDIF.



  ENDFORM.                    " GET_DATA
*  &---------------------------------------------------------------------*
*  &      Form  DISPLAY_DATA
*  &---------------------------------------------------------------------*
*         text
*  ----------------------------------------------------------------------*
*    -->  p1        text
*    <--  p2        text
*  ----------------------------------------------------------------------*
  FORM display_data .


    wa_fieldcat-fieldname 'MATNR'.
    wa_fieldcat-tabname 'IT_MARA.'.
    wa_fieldcat-seltext_m 'MAT_NO.'.
    APPEND wa_fieldcat TO  it_fieldcat.

    wa_fieldcat-fieldname 'ERSDA'.
    wa_fieldcat-tabname 'IT_MARA'.
    wa_fieldcat-seltext_m 'CRATED ON.'.
    APPEND wa_fieldcat TO  it_fieldcat.


    wa_fieldcat-fieldname 'MTART'.
    wa_fieldcat-tabname 'IT_MARA'.
    wa_fieldcat-seltext_m 'MAT_TYPE'.
    APPEND wa_fieldcat TO  it_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 '2ND-SCREEN'
*       I_CALLBACK_TOP_OF_PAGE  = ' '
*       I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*       I_CALLBACK_HTML_END_OF_LIST       = ' '
*       I_STRUCTURE_NAME        =
*       I_BACKGROUND_ID         = ' '
*       I_GRID_TITLE            =
*       I_GRID_SETTINGS         =
*       IS_LAYOUT               =
        it_fieldcat             it_fieldcat
*       IT_EXCLUDING            =
*       IT_SPECIAL_GROUPS       =
*       IT_SORT                 =
*       IT_FILTER               =
*     IS_SEL_HIDE             =
      i_default               'X'
      i_save                  'A'
*     IS_VARIANT              =
*     IT_EVENTS               =
*     IT_EVENT_EXIT           =
*     IS_PRINT                =
*     IS_REPREP_ID            =
*     I_SCREEN_START_COLUMN   = 0
*     I_SCREEN_START_LINE     = 0
*     I_SCREEN_END_COLUMN     = 0
*     I_SCREEN_END_LINE       = 0
*     I_HTML_HEIGHT_TOP       = 0
*     I_HTML_HEIGHT_END       = 0
*     IT_ALV_GRAPHICS         =
*     IT_HYPERLINK            =
*     IT_ADD_FIELDCAT         =
*     IT_EXCEPT_QINFO         =
*     IR_SALV_FULLSCREEN_ADAPTER        =
* IMPORTING
*     E_EXIT_CAUSED_BY_CALLER =
*     ES_EXIT_CAUSED_BY_USER  =
    TABLES
      t_outtab                itab[]
* 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.                    " DISPLAY_DATA



"************  At USER COMMAND **********************************

FORM 2nd-screen USING r_ucomm TYPE sy-ucomm         " CAPTURE CURSOR NEXT ACTION - LIKE SAVE, DOUBLE CLICK
                      r_sel TYPE slis_selfield.   " SLIS_SELFIELD - ---    CURSOR POSTION(VALUE)

  DATAvar1 TYPE mara-matnr.

  var1 r_sel-value.

  SELECT FROM makt INTO TABLE it_makt WHERE matnr var1.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_structure_name 'MAKT'
      i_default        'X'
    TABLES
      t_outtab         it_makt[]
    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.

Pages