Monday, September 25, 2023

ALV WITH HEADER AND FOOTER TEXT AND INSERTING LOGO IN REPORT

 

REPORT zalv_practice.

TABLESEKKOEKPO.
TYPES BEGIN OF TY_EKKO,
        EBELN TYPE EKKO-EBELN,
        BUKRS TYPE EKKO-BUKRS,
        LIFNR TYPE EKKO-LIFNR,
        SPRAS TYPE EKKO-SPRAS,
        END OF TY_EKKO.

TYPES BEGIN OF TY_EKPO,
        EBELN TYPE EKPO-EBELN,
        MATNR TYPE EKPO-MATNR,
        BUKRS TYPE EKPO-BUKRS,
        WERKS TYPE EKPO-WERKS,
        END OF TY_EKPO.

TYPES :BEGIN OF TY_FINAL,
        EBELN TYPE EKKO-EBELN,
        BUKRS TYPE EKKO-BUKRS,
        LIFNR TYPE EKKO-LIFNR,
        SPRAS TYPE EKKO-SPRAS,
        MATNR TYPE EKPO-MATNR,
        WERKS TYPE EKPO-WERKS,
       END OF TY_FINAL.

DATA:IT_EKKO TYPE TABLE OF TY_EKKO,
      WA_EKKO TYPE TY_EKKO.
DATA:IT_EKPO TYPE TABLE OF TY_EKPO,
      WA_EKPO TYPE TY_EKPO.
DATA IT_FINAL TYPE TABLE OF TY_FINAL,
       WA_FINAL TYPE TY_FINAL.

DATA IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
       WA_FCAT TYPE SLIS_FIELDCAT_ALV.

DATAIT_EVENT TYPE  SLIS_T_EVENT,
      WA_EVENT LIKE LINE OF IT_EVENT.

SELECT-OPTIONSS_EBELN FOR EKKO-EBELN.
SELECT-OPTIONSS_BUKRS FOR EKKO-BUKRS.

AT SELECTION-SCREEN.
START-OF-SELECTION.
PERFORM SUB_GET_EKKO.
PERFORM SUB_GET_EKPO.
PERFORM SUB_GET_FINAL.
PERFORM MAIN_FCAT.
PERFORM TOP.
PERFORM END.
PERFORM DISPLAY.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  SUB_GET_EKKO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sub_get_ekko .
SELECT EBELN  BUKRS LIFNR SPRAS
  FROM EKKO INTO TABLE IT_EKKO
  WHERE EBELN IN S_EBELN.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  SUB_GET_EKPO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sub_get_ekpo .
  IF IT_EKKO IS NOT INITIAL.
SELECT EBELN   MATNR BUKRS WERKS
  FROM EKPO INTO TABLE IT_EKPO
  FOR ALL ENTRIES IN IT_EKKO
  WHERE EBELN IT_EKKO-EBELN AND BUKRS =  IT_EKKO-BUKRS.
  IF SY-SUBRC EQ .
    SORT IT_EKKO BY EBELN.
    ENDIF.
  ENDIF.
ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  SUB_GET_FINAL
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM sub_get_final .
 IF IT_EKKO IS NOT INITIAL
  and   IT_EKPO IS NOT INITIAL.
  LOOP AT IT_EKKO INTO WA_EKKO.
  WA_FINAL-EBELN WA_EKKO-EBELN.
  WA_FINAL-BUKRS WA_EKKO-BUKRS.
  WA_FINAL-LIFNR WA_EKKO-LIFNR.
  WA_FINAL-SPRAS WA_EKKO-SPRAS.
  ENDLOOP.
LOOP AT IT_EKPO INTO WA_EKPO.
WA_FINAL-EBELN WA_EKPO-EBELN.
WA_FINAL-MATNR WA_EKPO-MATNR.
WA_FINAL-BUKRS WA_EKPO-BUKRS.
WA_FINAL-WERKS WA_EKPO-WERKS.

APPEND WA_FINAL TO IT_FINAL.
CLEAR :WA_FINALWA_EKKO,WA_EKPO.
ENDLOOP.
ENDIF.
ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  MAIN_FCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM main_fcat .
WA_FCAT-FIELDNAME 'EBELN'.
WA_FCAT-COL_POS '1'.
WA_FCAT-SELTEXT_L 'PUR.DOC.NO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME 'BUKRS'.
WA_FCAT-COL_POS '2'.
WA_FCAT-SELTEXT_L 'COMPANY.CODE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME 'LIFNR'.
WA_FCAT-COL_POS '3'.
WA_FCAT-SELTEXT_L 'VENDER'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME 'SPRAS'.
WA_FCAT-COL_POS '4'.
WA_FCAT-SELTEXT_L 'LANGUAGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME 'MATNR'.
WA_FCAT-COL_POS '5'.
WA_FCAT-SELTEXT_L 'MATERIALNO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME 'WERKS'.
WA_FCAT-COL_POS '6'.
WA_FCAT-SELTEXT_L 'PLANT'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_EVENT-NAME 'TOP_OF_PAGE'.
WA_EVENT-FORM 'TOP'.
APPEND WA_EVENT TO IT_EVENT.
WA_EVENT-NAME 'END_OF_LIST'.
WA_EVENT-FORM 'END'.
APPEND WA_EVENT TO IT_EVENT.
ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  TOP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM top .
DATA IT_LIST TYPE SLIS_T_LISTHEADER,
       WA_LIST LIKE LINE OF IT_LIST.
WA_LIST-INFO 'PURCHASE ORDER'.
WA_LIST-TYP 'H'.
APPEND WA_LIST TO IT_LIST.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    it_list_commentary       IT_LIST
   I_LOGO                   'SAPLOGO'
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
   .
ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  END
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM end .

DATA IT_LIST1 TYPE SLIS_T_LISTHEADER,
       WA_LIST1 LIKE LINE OF IT_LIST1.
WA_LIST1-INFO 'SQUIRREL,AHMEDABAD'.
WA_LIST1-TYP 'A'.
APPEND WA_LIST1 TO IT_LIST1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    it_list_commentary       IT_LIST1
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
*   I_ALV_FORM               =
  .

ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  SUB_DISPLAY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM display .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*     I_INTERFACE_CHECK                 = ' '
*     I_BYPASSING_BUFFER                = ' '
*     I_BUFFER_ACTIVE                   = ' '
     I_CALLBACK_PROGRAM                SY-CPROG
*     I_CALLBACK_PF_STATUS_SET          = ' '
*     I_CALLBACK_USER_COMMAND           = ' '
*     I_CALLBACK_TOP_OF_PAGE            = IT_LIST
*     I_CALLBACK_HTML_TOP_OF_PAGE       = IT_LIST
*     I_CALLBACK_HTML_END_OF_LIST       = IT_LIST1
*     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
*     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.
* Implement suitable error handling here
  ENDIF.
ENDFORM.


OUTPUT:


















No comments:

Post a Comment

Translation of language in Smart Forms.

  Step by Step process to Translate English language to Spanish language in smart form. 1. Go to T-Code SE63 in command bar and then enter. ...