Saturday 22 October 2022

How to Add a Custom Field to QA11

I am a SAP ABAP consultant and recently I have been requested to make enhancements to QA11 screen. After some research, I could manage to put things together. And I thought, it is worth creating a complete tutorial on that topic.

Therefore, in this article, I would to share with you how to add the material group field to the QA11 screen and QALS table.

We need to complete following steps;

◉ Add our custom Z field to structure
◉ We create a Function Group.
    ◉ We are creating a screen.
    ◉ We write the input and output codes.
    ◉ We create functions.
◉ We are creating BAdI implementation.
    ◉ We enter the filter value and screen information.
    ◉ We write the GET_DATA and PUT_DATA methods.

BAdI used: QEVA_SUBSCREEN_1101

First, we add our field to the QALS table. Go to SE11 > QALS > CI_QALS

We add our field, starting with ZZ.

Field name: ZZMATKL

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

After adding the field, we create the Function Group for the screen that we will add to the BAdI.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

Then we create a Z screen to show the field we added to the QALS table in QA11.

Don’t forget to choose Subscreen.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

We fill the TOP include of the Function Group we created as follows.

We will use the variables we defined in the get_data and put_data methods.

TABLES: qals_cust.
DATA: display          TYPE c,
      s_qals           TYPE qals,
      subscr_1101_qeva TYPE REF TO if_ex_qeva_subscreen_1101,
      flt_val          TYPE qherk,
      s_rqeva          TYPE rqeva.
 
We add the area to the screen.

We will use the qals_cust we added to the code in the field on the screen.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

When QA11 is opened for the if_ex_qeva_subscreen_1101 interface, we create our reference for the get_data and put_data methods.

We enter the PBO information for the Screen.

MODULE status_1101 OUTPUT.

  IF subscr_1101_qeva IS INITIAL.
    CALL METHOD cl_exithandler=>get_instance_for_subscreens
      CHANGING
        instance                      = subscr_1101_qeva
      EXCEPTIONS
        no_reference                  = 1
        no_interface_reference        = 2
        no_exit_interface             = 3
        data_incons_in_exit_managem   = 4
        class_not_implement_interface = 5
        OTHERS                        = 6.

    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.

ENDMODULE.

We call the information we entered in the ZZMATKL field in the PAI section. Then we give it to the get_data method.

We enter the PAI information for the Screen.

MODULE user_command_1101 INPUT.

  MOVE-CORRESPONDING qals_cust TO s_qals.

  IF subscr_1101_qeva IS NOT INITIAL .
    CALL METHOD subscr_1101_qeva->get_data
      EXPORTING
        flt_val = flt_val
      IMPORTING
        e_qals  = s_qals
        e_rqeva = s_rqeva.

  ENDIF .

ENDMODULE.
 
We create the GET_DATA and PUT_DATA functions.

In the function below, we transfer the values from the screen.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

FUNCTION zed_fm_qa11_get_data.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     REFERENCE(E_QALS) TYPE  QALS
*"     REFERENCE(E_RQEVA) TYPE  RQEVA
*"----------------------------------------------------------------------

  MOVE-CORRESPONDING: s_qals TO e_qals.

ENDFUNCTION.

In the function below, we get the information from the screen.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

FUNCTION zed_fm_qa11_put_data.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_QALS) TYPE  QALS OPTIONAL
*"     REFERENCE(I_RQEVA) TYPE  RQEVA OPTIONAL
*"     REFERENCE(I_QHERK) TYPE  QHERK OPTIONAL
*"----------------------------------------------------------------------

  MOVE-CORRESPONDING: i_qals  TO qals_cust,
                      i_qals  TO s_qals,
                      i_rqeva TO s_rqeva.

  MOVE i_qherk TO flt_val.

ENDFUNCTION.

Create BAdI Implementation

We implement the QEVA_SUBSCREEN_1101 BAdI that we need for the QA11 screen.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

Don’t forget to add the filter value.

We specify in which control batch it will work.

We write the Function Group and Screen names we created in the Program called and Dynpro fields.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

We activate development.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

We move on to writing code to the GET_DATA and PUT_DATA methods.

We call the data on the screen with the GET_DATA method.

  METHOD IF_EX_QEVA_SUBSCREEN_1101~GET_DATA.

    DATA: PROGRAM_NAME TYPE STRING VALUE '(SAPMQEVA)QALS',
          INFOS        TYPE CI_QALS,
          CUST         TYPE CI_QALS.
    FIELD-SYMBOLS:<FS_INFO> TYPE QALS .

    CALL FUNCTION 'ZED_FM_QA11_GET_DATA'
      IMPORTING
        E_QALS  = E_QALS
        E_RQEVA = E_RQEVA.

    MOVE-CORRESPONDING E_QALS TO IF_EX_QEVA_SUBSCREEN_1101~G_QALS .
    ASSIGN (PROGRAM_NAME) TO <FS_INFO> .

    IF SY-SUBRC IS INITIAL.

      MOVE-CORRESPONDING E_QALS TO CUST .
      MOVE-CORRESPONDING CUST TO <FS_INFO> .
    ENDIF .

  ENDMETHOD.

With PUT_DATA, we put the data on the screen.

  METHOD IF_EX_QEVA_SUBSCREEN_1101~PUT_DATA.

    DATA: S_QALS TYPE QALS.

    IF IF_EX_QEVA_SUBSCREEN_1101~G_QALS IS NOT INITIAL .

      MOVE-CORRESPONDING IF_EX_QEVA_SUBSCREEN_1101~G_QALS TO S_QALS .
    ELSE.

      MOVE-CORRESPONDING I_QALS TO S_QALS .
    ENDIF .

    CALL FUNCTION 'ZED_FM_QA11_PUT_DATA'
      EXPORTING
        I_QALS  = S_QALS
        I_RQEVA = I_RQEVA
        I_QHERK = FLT_VAL.

  ENDMETHOD.

That’s all. Now those changes, we have completed the steps to add a new fields to QA11 screen.

QA11 Screen

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

You can see the value in the ZZMATKL field added to the QALS table.

SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Prep, SAP ABAP Preparation, SAP ABAP Tutorial and Materials

Those are all the steps to enhance QA11 screen.

No comments:

Post a Comment