FOR ALL ENTRIES (FAE) -4 TABLES USING ALV_GRID_DISPLAY

*&---------------------------------------------------------------------*
*& Report  ZFAE_ALV
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZFAE_ALV.

TYPE-POOLS: SLIS.

TYPES: BEGIN OF TY_VBAK,
        VBELN TYPE VBAK-VBELN,
        ERNAM TYPE VBAK-ERNAM,
        KUNNR TYPE VBAK-KUNNR,
      END OF TY_VBAK.

 TYPES: BEGIN OF TY_VBAP,
         VBELN TYPE VBAP-VBELN,
         POSNR TYPE VBAP-POSNR,
         MATNR TYPE VBAP-MATNR,
       END OF TY_VBAP.

 TYPES:BEGIN OF TY_MARA,
       MATNR TYPE MARA-MATNR,
       MBRSH TYPE MARA-MBRSH,
       END OF TY_MARA.

 TYPES: BEGIN OF TY_MAKT,
        MATNR TYPE MAKT-MATNR,
        MAKTX TYPE MAKT-MAKTX,
        END OF TY_MAKT.


 TYPES:BEGIN OF TY_FINAL,
         VBELN TYPE VBAK-VBELN,
        ERNAM TYPE VBAK-ERNAM,
        KUNNR TYPE VBAK-KUNNR,
        POSNR TYPE VBAP-POSNR,
         MATNR TYPE VBAP-MATNR,
         MBRSH TYPE MARA-MBRSH,
         MAKTX TYPE MAKT-MAKTX,
        END OF TY_FINAL.


 DATA: IT_VBAK TYPE TABLE OF TY_VBAK,
       IT_VBAP TYPE TABLE OF TY_VBAP,
       IT_FINAL TYPE TABLE OF TY_FINAL,
       IT_MARA TYPE TABLE OF TY_MARA,
       IT_MAKT TYPE TABLE OF TY_MAKT,
       WA_VBAK TYPE TY_VBAK,
       WA_VBAP TYPE TY_VBAP,
       WA_FINAL TYPE TY_FINAL,
       WA_MARA TYPE TY_MARA,
       WA_MAKT TYPE TY_MAKT.

DATA:IT_FCAT TYPE  SLIS_T_FIELDCAT_ALV ,
      WA_FCAT LIKE LINE OF IT_FCAT.

 SELECT-OPTIONS: S_VBELN FOR WA_VBAK-VBELN.


  START-OF-SELECTION.


   PERFORM FETCH_DATA.
   PERFORM FCATE.

   PERFORM DISPLAY_DATA.
*&---------------------------------------------------------------------*
*&      Form  FETCH_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FETCH_DATA .

SELECT VBELN
         ERNAM
        KUNNR FROM VBAK
        INTO TABLE IT_VBAK
        WHERE VBELN IN S_VBELN.

  IF IT_VBAK IS NOT INITIAL.

    SELECT  VBELN
         POSNR
         MATNR FROM VBAP
          INTO TABLE IT_VBAP
          FOR ALL ENTRIES IN IT_VBAK
         WHERE VBELN = IT_VBAK-VBELN.


  ENDIF.


  IF IT_VBAP IS NOT INITIAL.

    SELECT MATNR MBRSH
          FROM MARA
         INTO TABLE IT_MARA
          FOR ALL ENTRIES IN IT_VBAP
         WHERE MATNR = IT_VBAP-MATNR.

  ENDIF.

  IF IT_MARA IS NOT INITIAL.

    SELECT MATNR MAKTX
          FROM MAKT
         INTO TABLE IT_MAKT
          FOR ALL ENTRIES IN IT_MARA
         WHERE MATNR = IT_MARA-MATNR.

  ENDIF.


  LOOP AT  IT_VBAK INTO WA_VBAK.

    READ TABLE IT_VBAP INTO WA_VBAP WITH  KEY VBELN = WA_VBAK-VBELN .

READ TABLE IT_MARA INTO WA_MARA WITH  KEY MATNR = WA_VBAP-MATNR.

READ TABLE IT_MAKT INTO WA_MAKT WITH  KEY MATNR = WA_MARA-MATNR.


    WA_FINAL-VBELN = WA_VBAK-VBELN.
    WA_FINAL-POSNR = WA_VBAP-POSNR.
    WA_FINAL-MATNR = WA_VBAP-MATNR.
    WA_FINAL-ERNAM = WA_VBAK-ERNAM.
    WA_FINAL-KUNNR = WA_VBAK-KUNNR.
     WA_FINAL-MBRSH = WA_MARA-MBRSH.
     WA_FINAL-MAKTX = WA_MAKT-MAKTX.

    APPEND  WA_FINAL TO IT_FINAL.
    CLEAR WA_FINAL.


*
*
*
*     APPEND  WA_FINAL TO IT_FINAL.
*    CLEAR WA_FINAL.



  ENDLOOP.





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


  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                         =
     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_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.                    " DISPLAY_DATA
*&---------------------------------------------------------------------*
*&      Form  FCATE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FCATE .

WA_FCAT-COL_POS = 1.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-TABNAME = 'VBAP'.
WA_FCAT-SELTEXT_M = 'SALES DOC NO'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = 2.
WA_FCAT-FIELDNAME = 'ERNAM'.
WA_FCAT-TABNAME = 'VBAP'.
WA_FCAT-SELTEXT_M = 'SALES DOC NAME'.
*WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = 3.
WA_FCAT-FIELDNAME = 'KUNNR'.
WA_FCAT-TABNAME = 'VBAP'.
WA_FCAT-SELTEXT_M = 'SOLD_TO_PARTY'.
*WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.



WA_FCAT-COL_POS = 4.
WA_FCAT-FIELDNAME = 'POSNR'.
WA_FCAT-TABNAME = 'VBAK'.
WA_FCAT-SELTEXT_M = 'BILLING'.
*WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.


WA_FCAT-COL_POS = 5.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-TABNAME = 'VBAP'.
WA_FCAT-SELTEXT_M = 'MATERIAL NO'.
*WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.


WA_FCAT-COL_POS = 6.
WA_FCAT-FIELDNAME = 'MBRSH'.
WA_FCAT-TABNAME = 'MARA'.
WA_FCAT-SELTEXT_M = 'MATERIAL TYPE'.
*WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-COL_POS = 7.
WA_FCAT-FIELDNAME = 'MAKTX'.
WA_FCAT-TABNAME = 'MAKT'.
WA_FCAT-SELTEXT_M = 'MATERIAL DESCRI'.
*WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.


ENDFORM.                    " FCATE




SAVE AND CHECK AND ACTIVE.


EXECUTE IT.
  

Comments

  1. we provide a best modules in sap and (selenium) softwaare testing with real time scenarios.
    Our consultants are working professionals they will share our experience
    Who can learn in this module?
    Opportunities in this Module?
    Why Prefer Training with US?
    Training by Leading Architects
    Topic based Training
    Long-Term Technical Support
    Placement Assistance
    End to End – Project Support
    SAP HR Training in Chennai
    SAP Success Factors Training in Chennai
    SAP FICO Training in Chennai
    SAP MM Training in Chennai
    Sap Fiori Training in Chennai
    SAP HANA Training in Chennai
    software Testing modules
    Selenium Training in Chennaiss
    for more informations call 8122241286

    ReplyDelete
  2. This post is extremely radiant. I extremely like this post. It is outstanding amongst other posts that I’ve read in quite a while. Much obliged for this better than average post. I truly value it! sap training institutes in hyderabad with placements

    ReplyDelete
  3. This post is extremely radiant. I extremely like this post. It is outstanding amongst other posts that I’ve read in quite a while. Much obliged for this better than average post. I truly value it! sap best training institute in hyderabad

    ReplyDelete
  4. For any software developer, sap course in Kochi can seem like an overwhelming topic to address. One of the most searched certification courses is SAP.

    ReplyDelete

Post a Comment

Popular posts from this blog

RADIO-BUTTONS IN BASIC REPORT

MODULE POOL -TABLE CONTROL_1: