Control Break Statement Program in SAP ABAP


Code :
REPORT ZVP_CONTROL_BREAK.

TYPESBEGIN OF TY_MARC,
         MATNR TYPE MARC-MATNR,
         WERKS TYPE MARC-WERKS,
       END OF TY_MARC.

DATAIT_MARC TYPE TABLE OF TY_MARC,
      WA_MARC TYPE TY_MARC,
      WA_TEMP TYPE TY_MARC.


SELECT MATNR
       WERKS
  FROM MARC INTO TABLE IT_MARC UP TO 20 ROWS.
DELETE IT_MARC WHERE MATNR SPACE.

WRITE:'FULL TABLE'.
LOOP AT IT_MARC INTO WA_MARC.
  WRITE:/ SY-TABIX,
          WA_MARC-MATNR,
          WA_MARC-WERKS.
ENDLOOP.

WRITE:'AT FIRST'.
LOOP AT IT_MARC INTO WA_MARC.
  WA_TEMP WA_MARC.
  AT FIRST.
    WRITE:/ SY-TABIX,
              WA_TEMP-MATNR,
              WA_TEMP-WERKS.
  ENDAT.
ENDLOOP.

WRITE:'AT LAST'.
LOOP AT IT_MARC INTO WA_MARC.
  WA_TEMP WA_MARC.
  AT LAST.
    WRITE:/ SY-TABIX,
              WA_TEMP-MATNR,
              WA_TEMP-WERKS.
  ENDAT.
ENDLOOP.

WRITE:'AT NEW'.
LOOP AT IT_MARC INTO WA_MARC.
  WA_TEMP WA_MARC.
  AT NEW MATNR.
    WRITE:/ SY-TABIX,
              WA_TEMP-MATNR,
              WA_TEMP-WERKS.
  ENDAT.
ENDLOOP.

WRITE:'AT END OF'.
LOOP AT IT_MARC INTO WA_MARC.
  WA_TEMP WA_MARC.
  AT END OF MATNR.
    WRITE:/ SY-TABIX,
              WA_TEMP-MATNR,
              WA_TEMP-WERKS.
  ENDAT.
ENDLOOP.

Output :


IDE Used To Test This Code : SAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

ALV Subtotal Program in SAP ABAP


Code :
REPORT ZVP_ALV_SUBTOTAL.

TYPE-POOLSSLIS.

TYPESBEGIN OF TY_VBAP,
        VBELN TYPE VBAP-VBELN,
        MATNR TYPE VBAP-MATNR,
        POSAR TYPE VBAP-POSAR,
        NETPR TYPE VBAP-NETPR,
      END OF TY_VBAP.

DATAIT_VBAP TYPE TABLE OF TY_VBAP,
      WA_VBAP TYPE TY_VBAP,

      IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT TYPE SLIS_FIELDCAT_ALV,
      IT_SORT   TYPE SLIS_T_SORTINFO_ALV,
      WA_SORT   TYPE SLIS_SORTINFO_ALV,
      WA_LAYOUT TYPE SLIS_LAYOUT_ALV.


SELECT  VBELN
        MATNR
        POSAR
        NETPR
  FROM VBAP INTO TABLE IT_VBAP UP TO 12 ROWS.


WA_FCAT-COL_POS '1'.
WA_FCAT-FIELDNAME 'VBELN'.
WA_FCAT-SELTEXT_M 'VBELN'.
APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-COL_POS '2'.
WA_FCAT-FIELDNAME 'MATNR'.
WA_FCAT-SELTEXT_M 'MATNR'.
APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-COL_POS '3'.
WA_FCAT-FIELDNAME 'POSAR'.
WA_FCAT-SELTEXT_M 'POSAR'.
APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-COL_POS '4'.
WA_FCAT-FIELDNAME 'NETPR'.
WA_FCAT-SELTEXT_M 'NETPR'.
WA_FCAT-DO_SUM 'X'.
APPEND WA_FCAT TO IT_FCAT.

WA_SORT-SPOS '2'.
WA_SORT-FIELDNAME 'MATNR'.
WA_SORT-UP 'X'.
WA_SORT-SUBTOT 'X'.
APPEND WA_SORT TO IT_SORT.


WA_LAYOUT-COLWIDTH_OPTIMIZE 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
 EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
*   I_CALLBACK_PROGRAM                = ' '
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   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                         WA_LAYOUT
   IT_FIELDCAT                       IT_FCAT
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
   IT_SORT                           IT_SORT
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   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                          IT_VBAP
* EXCEPTIONS
*   PROGRAM_ERROR                     = 1
*   OTHERS                            = 2
          .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.


Output :

IDE Used To Test This Code : ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Traffic light program in SAP ABAP


Code :
REPORT ZVP_TRAFFIC_LIGHT_PROGRAM.

TYPE-POOLSSLIS.

TYPESBEGIN OF TY_MARA,
         MATNR  TYPE MARA-MATNR,
         MTART  TYPE MARA-MTART,
         MATKL  TYPE MARA-MATKL,
         GROES  TYPE MARA-GROES,
         NTGEW  TYPE MARA-NTGEW,
         LIGHTS TYPE C,
       END OF TY_MARA.


DATAIT_MARA   TYPE STANDARD TABLE OF TY_MARA,
      WA_MARA   TYPE TY_MARA,

      IT_FCAT   TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT   TYPE SLIS_FIELDCAT_ALV,
      WA_LAYOUT TYPE SLIS_LAYOUT_ALV,

      LV_MATNR  TYPE MARA-MATNR.

SELECT-OPTIONSS_MATNR FOR LV_MATNR.


SELECT MATNR
       MTART
       MATKL
       GROES
       NTGEW
  FROM MARA INTO TABLE IT_MARA WHERE MATNR IN S_MATNR.

PERFORM CALL_ALV.


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           = ' '
*   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          WA_LAYOUT
    IT_FIELDCAT        IT_FCAT
*   IT_EXCLUDING       =
*   IT_SPECIAL_GROUPS  =
*   IT_SORT            =
*   IT_FILTER          =
*   IS_SEL_HIDE        =
*   I_DEFAULT          = 'X'
*   I_SAVE             = ' '
*   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           IT_MARA
* EXCEPTIONS
*   PROGRAM_ERROR      = 1
*   OTHERS             = 2
  .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

FORM CALL_ALV.

  LOOP AT IT_MARA INTO WA_MARA.
    IF
      WA_MARA-MATKL 'XLCL'.
      WA_MARA-LIGHTS 1.
    ELSEIF
      WA_MARA-MATKL 'XLVL'.
      WA_MARA-LIGHTS 2.
    ELSE.
      WA_MARA-LIGHTS 3.
    ENDIF.
    MODIFY IT_MARA FROM WA_MARA TRANSPORTING LIGHTS.
    CLEAR WA_MARA.
  ENDLOOP.


  WA_FCAT-COL_POS '1'.
  WA_FCAT-FIELDNAME 'MATNR'.
  WA_FCAT-SELTEXT_M 'MATERIAL NUMBER'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.

  WA_FCAT-COL_POS '2'.
  WA_FCAT-FIELDNAME 'MTART'.
  WA_FCAT-SELTEXT_M 'MTART'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.

  WA_FCAT-COL_POS '3'.
  WA_FCAT-FIELDNAME 'MATKL'.
  WA_FCAT-SELTEXT_M 'MATKL'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.

  WA_FCAT-COL_POS '4'.
  WA_FCAT-FIELDNAME 'GROES'.
  WA_FCAT-SELTEXT_M 'GROES'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.

  WA_FCAT-COL_POS '5'.
  WA_FCAT-FIELDNAME 'NTGEW'.
  WA_FCAT-SELTEXT_M 'NTGEW'.
  APPEND WA_FCAT TO IT_FCAT.
  CLEAR WA_FCAT.

  WA_LAYOUT-LIGHTS_FIELDNAME 'LIGHTS'.
ENDFORM.

Output :

 

IDE Used To Test This Code : ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

How to show Excel data to Internal Table in SAP ABAP


EXCEL DATA

Code :
REPORT ZVP_EXCEL_TO_INTERNAL_TABLE.

TYPE-POOLSTRUXS.

TYPESBEGIN OF STRC,
         ID   TYPE CHAR10,
         NAME TYPE CHAR10,
         AGE  TYPE CHAR10,
       END OF STRC.

DATAIT_STRC TYPE TABLE OF STRC,
      WA_STRC TYPE STRC.

DATAIT_RAW TYPE TRUXS_T_TEXT_DATA.

PARAMETERSP_FILE TYPE RLGRAP-FILENAME.

**************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
*     PROGRAM_NAME        = SYST-CPROG
*     DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME 'P_FILE'
    IMPORTING
      FILE_NAME  P_FILE.
**************************************************************

**************************************************************
START-OF-SELECTION.
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
*     I_FIELD_SEPERATOR    =
      I_LINE_HEADER        'X'
      I_TAB_RAW_DATA       IT_RAW
      I_FILENAME           P_FILE
    TABLES
      I_TAB_CONVERTED_DATA IT_STRC
    EXCEPTIONS
      CONVERSION_FAILED    1
      OTHERS               2.

  IF IT_STRC IS INITIAL.
    MESSAGE'EMPTY' TYPE 'I'.
  ENDIF.

END-OF-SELECTION.
*************************************************************

  LOOP AT IT_STRC INTO WA_STRC.
      WRITE:/ WA_STRC-ID,
              WA_STRC-NAME,
              WA_STRC-AGE.
  ENDLOOP.
  .


Output :


IDE Used To Test This Code : ABAP Editor

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

How to change Radio button text alignment in SAP ABAP


Code :
REPORT ZVP_RADIO_BUTTON_POSITION.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(10TEXT-001.
PARAMETERSRB1 RADIOBUTTON GROUP RBG.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 2(10TEXT-002.
PARAMETERSRB2 RADIOBUTTON GROUP RBG.
SELECTION-SCREEN END OF LINE.


Note: Goto - Text Elements - Text Symbols - Put the name of button.

Output :

IDE Used To Test This Code : ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Dynamic Radio button program in SAP ABAP


Requirement : We have total 6 radio button in the below program. we want to show radio button based upon the RB1 and RB2.

Total radio buttons are  - RB1, RB2, RB3, RB4, RB5, RB6.

When we click RB1 then RB3 and RB4 radio button will show, RB5 and RB6 will be hidden.
When we click RB2 then RB5 and RB6 radio button will show, RB3 and RB4 will be hidden.


Code :
REPORT ZVP_RADIO_BUTTON_DYNAMIC.

SELECTION-SCREENBEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-100.
PARAMETERSRB1 RADIOBUTTON GROUP RBG DEFAULT 'X' USER-COMMAND COMM,
            RB2 RADIOBUTTON GROUP RBG.

SELECTION-SCREENBEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.
PARAMETERSRB3 RADIOBUTTON GROUP RBG1 MODIF ID MD1,
            RB4 RADIOBUTTON GROUP RBG1 MODIF ID MD1.
SELECTION-SCREENEND OF BLOCK B2.

SELECTION-SCREENBEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-102.
PARAMETERSRB5 RADIOBUTTON GROUP RBG2 MODIF ID MD2,
            RB6 RADIOBUTTON GROUP RBG2 MODIF ID MD2.
SELECTION-SCREENEND OF BLOCK B3.

SELECTION-SCREENEND OF BLOCK B1.


AT SELECTION-SCREEN OUTPUT.
  IF RB1 'X'.
    LOOP AT SCREEN.
      IF SCREEN-GROUP1 'MD1'.
        SCREEN-ACTIVE 1.
        MODIFY SCREEN.
      ELSEIF SCREEN-GROUP1 'MD2'.
        SCREEN-ACTIVE 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN.
      IF SCREEN-GROUP1 'MD1'.
        SCREEN-ACTIVE 0.
        MODIFY SCREEN.
      ELSEIF SCREEN-GROUP1 'MD2'.
        SCREEN-ACTIVE 1.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

IDE Used To Test This Code : ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

SELECT-OPTIONS in SAP ABAP


OBLIGATORY
Code :
REPORT ZVP_SELECT_OPTION.

DATALV_MATNR  TYPE MARA-MATNR.

SELECT-OPTIONSS_MATNR FOR LV_MATNR OBLIGATORY.

Output :

NO-DISPLAY
Code :
REPORT ZVP_SELECT_OPTION.

DATA: LV1_MATNR TYPE MARA-MATNR.

SELECT-OPTIONS: S1_MATNR FOR LV1_MATNR NO-DISPLAY.


NO-EXTENSION
Code :
REPORT ZVP_SELECT_OPTION.

DATA: LV2_MATNR TYPE MARA-MATNR.

SELECT-OPTIONS: S2_MATNR FOR LV2_MATNR NO-EXTENSION.

Output :


NO INTERVALS
Code :
REPORT ZVP_SELECT_OPTION.

DATA: LV3_MATNR TYPE MARA-MATNR.

SELECT-OPTIONS: S3_MATNR FOR LV3_MATNR NO INTERVALS.

Output :

IDE Used To Test This Code : SAP Login 730.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

String search in Internal Table in SAP ABAP


Code :
REPORT ZVP_INTERNAL_TBL_STRING_SEARCH.

TYPESBEGIN OF STR,
         ID   TYPE CHAR10,
         NAME TYPE CHAR10,
       END OF STR.

DATAIT_STR TYPE STANDARD TABLE OF STR,
      WA_STR TYPE STR.

WA_STR-ID '1'.
WA_STR-NAME 'SUJOY'.
APPEND WA_STR TO IT_STR.
CLEAR WA_STR.

WA_STR-ID '2'.
WA_STR-NAME 'KAMAL'.
APPEND WA_STR TO IT_STR.
CLEAR WA_STR.

WA_STR-ID '3'.
WA_STR-NAME 'BIJOY'.
APPEND WA_STR TO IT_STR.
CLEAR WA_STR.

WA_STR-ID '4'.
WA_STR-NAME 'NANDAN'.
APPEND WA_STR TO IT_STR.
CLEAR WA_STR.

LOOP AT IT_STR INTO WA_STR.
  SEARCH WA_STR-NAME FOR '*OY'.
  IF SY-SUBRC EQ 0.
    WRITE:/ WA_STR-ID,
    WA_STR-NAME.
  ENDIF.
ENDLOOP.


Output :

IDE Used To Test This Code : SAP Login 730.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

How to Initialize a value in Parameter in SAP ABAP


Code :
REPORT ZVP_INIT.

PARAMETERSP_NAME TYPE CHAR10.

INITIALIZATION.
P_NAME 'WORLD'.


Output :

IDE Used To Test This Code : SAP Login 730.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Custom F4 Help program in SAP ABAP


Code :
REPORT ZVP_F4_HELP.

PARAMETERSP_NAME TYPE CHAR10.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_NAME.
  PERFORM GET_HELP.

AT SELECTION-SCREEN.
  IF P_NAME 'HELLO'.
    MESSAGE 'SUCCESS' TYPE 'S'.
  ENDIF.

FORM GET_HELP.

  TYPESBEGIN OF TY_HELP,
           NAME TYPE CHAR15,
         END OF TY_HELP.

  DATAIT_HELP   TYPE STANDARD TABLE OF TY_HELP,
        WA_HELP   TYPE TY_HELP,

        IT_RETURN TYPE TABLE OF DDSHRETVAL,
        WA_RETURN TYPE DDSHRETVAL.

  WA_HELP-NAME 'HELLO'.
  APPEND WA_HELP TO IT_HELP.
  CLEAR WA_HELP.

  WA_HELP-NAME 'WORLD'.
  APPEND WA_HELP TO IT_HELP.
  CLEAR WA_HELP.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      RETFIELD   'NAME'
      VALUE_ORG  'S'
    TABLES
      VALUE_TAB  IT_HELP
      RETURN_TAB IT_RETURN.

*read and transfer the selected value to field / parameter.
  READ TABLE IT_RETURN INTO WA_RETURN INDEX 1.
  P_NAME WA_RETURN-FIELDVAL.

ENDFORM.


Output :

IDE Used To Test This Code : SAP Login 730.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Sum of a series program in CPP


Code :
#include<iostream>
#include<conio.h>
using namespace std;
int main() {
int i, number, sum=0;
cout<<"Enter the limit : ";
cin>>number;
for(i=1; i<=number; i++) {
    sum = sum + i;
}
cout<<"Sum of given series : "<<sum;
return 0;
}


Output :



IDE Used To Test This Code : DEV C++.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Parallel Cursor program in SAP ABAP


Code :
REPORT ZVP_PARALLEL_CURSOR.

TYPESBEGIN OF EMP,
         ID   TYPE I,
         NAME TYPE CHAR10,
       END OF EMP.

TYPES:  BEGIN OF SAL,
          ID     TYPE I,
          MONTH  TYPE CHAR10,
          SALARY TYPE I,
        END OF SAL.

DATAIT_EMP   TYPE STANDARD TABLE OF EMP,
      WA_EMP   TYPE EMP,
      IT_SAL   TYPE STANDARD TABLE OF SAL,
      WA_SAL   TYPE SAL,
      LV_INDEX TYPE I.

WA_EMP-ID '1'.
WA_EMP-NAME 'AAA'.
APPEND WA_EMP TO IT_EMP.

WA_EMP-ID '2'.
WA_EMP-NAME 'BBB'.
APPEND WA_EMP TO IT_EMP.

WA_EMP-ID '3'.
WA_EMP-NAME 'CCC'.
APPEND WA_EMP TO IT_EMP.

WA_SAL-ID '3'.
WA_SAL-MONTH 'MAY'.
WA_SAL-SALARY '3000'.
APPEND WA_SAL TO IT_SAL.

WA_SAL-ID '1'.
WA_SAL-MONTH 'JUNE'.
WA_SAL-SALARY '1000'.
APPEND WA_SAL TO IT_SAL.

WA_SAL-ID '2'.
WA_SAL-MONTH 'JULY'.
WA_SAL-SALARY '2000'.
APPEND WA_SAL TO IT_SAL.

SORTIT_EMPIT_SAL.

LOOP AT IT_EMP INTO WA_EMP.

  READ TABLE IT_SAL INTO WA_SAL WITH KEY ID WA_EMP-ID.
  IF SY-SUBRC 0.
    LV_INDEX SY-TABIX.

    LOOP AT IT_SAL INTO WA_SAL FROM LV_INDEX .
      IF WA_EMP-ID <> WA_SAL-ID.
        EXIT.
      ENDIF.

      WRITE:/ WA_EMP-ID,'|',
              WA_EMP-NAME,'|',
              WA_SAL-MONTH,'|',
              WA_SAL-SALARY,'|'.
    ENDLOOP.
  ENDIF.
ENDLOOP.


Output :

IDE Used To Test This Code : SAP Login 730.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

ALV program using Subroutine in SAP ABAP


Code :
REPORT ZVP_ALV_EKPO_DETAILS.

TYPE-POOLSSLIS.

TYPESBEGIN OF ST_EKPO,
         EBELN TYPE EBELN,
         MATNR TYPE MATNR,
         EMATN TYPE EMATN,
         BUKRS TYPE BUKRS,
       END OF ST_EKPO.


DATAIT_EKPO   TYPE STANDARD TABLE OF ST_EKPO,
      WA_EKPO   TYPE ST_EKPO,

      IT_FCAT   TYPE SLIS_T_FIELDCAT_ALV,
      WA_FCAT   TYPE SLIS_FIELDCAT_ALV,
      WA_LAYOUT TYPE SLIS_LAYOUT_ALV,

      LV_EBELN  TYPE EKPO-EBELN.

SELECT-OPTIONSS_EBELN FOR LV_EBELN.

SELECT EBELN
       MATNR
       BUKRS
  FROM EKPO INTO TABLE IT_EKPO UP TO 50 ROWS
  WHERE EBELN IN S_EBELN.

PERFORM GETDETAILS.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
    IS_LAYOUT   WA_LAYOUT
    IT_FIELDCAT IT_FCAT
  TABLES
    T_OUTTAB    IT_EKPO.


FORM GETDETAILS.
  WA_FCAT-COL_POS '1'.
  WA_FCAT-FIELDNAME 'EBELN'.
  WA_FCAT-SELTEXT_M 'Purchasing Document Number'.
  APPEND WA_FCAT TO IT_FCAT.

  WA_FCAT-COL_POS '2'.
  WA_FCAT-FIELDNAME 'MATNR'.
  WA_FCAT-SELTEXT_M 'Material Number'.
  APPEND WA_FCAT TO IT_FCAT.

  WA_FCAT-COL_POS '3'.
  WA_FCAT-FIELDNAME 'BURKS'.
  WA_FCAT-SELTEXT_M 'Company Code'.
  APPEND WA_FCAT TO IT_FCAT.

  WA_LAYOUT-COLWIDTH_OPTIMIZE 'X'.
ENDFORM.


Output :


IDE Used To Test This Code : SAP Login 730.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.