Skip to Content
author's profile photo Former Member
Former Member

ALV REPORT (urgent)

how to develop alv report using function modules which can be sent to a file, dowloaded to excel, columns removed or added, the report can be resorted.the above can all be done by user interaction once the report is genaerated. and the report will be having hotspots ,once clicked on particular column should go to particular transaction.(with code)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 06:45 AM

    Check the following codes:

    *&---------------------------------------------------------------------*
    *& Report  ZDEMO_ALVGRID                                               *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *&                                                                     *
    *& Example of a simple ALV Grid Report                                 *
    *& ...................................                                 *
    *&                                                                     *
    *& The basic ALV grid, Enhanced to display each row in a different     *
    *& colour                                                              *
    *&---------------------------------------------------------------------*
    
    REPORT  zdemo_alvgrid                 .
    
    TABLES:     ekko.
    
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    *----------------
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      line_color(4) type c,     "Used to store row color attributes
     END OF t_ekko.
    
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    
    
    ************************************************************************
    *Start-of-selection.
    START-OF-SELECTION.
    
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    
    
    *&---------------------------------------------------------------------*
    *&      Form  BUILD_FIELDCATALOG
    *&---------------------------------------------------------------------*
    *       Build Fieldcatalog for ALV Report
    *----------------------------------------------------------------------*
    form build_fieldcatalog.
    
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
    
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    
    
    *&---------------------------------------------------------------------*
    *&      Form  BUILD_LAYOUT
    *&---------------------------------------------------------------------*
    *       Build layout for ALV grid report
    *----------------------------------------------------------------------*
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    * Set layout field for row attributes(i.e. color) 
      gd_layout-info_fieldname =      'LINE_COLOR'.
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    
    
    *&---------------------------------------------------------------------*
    *&      Form  DISPLAY_ALV_REPORT
    *&---------------------------------------------------------------------*
    *       Display report using ALV grid
    *----------------------------------------------------------------------*
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
    
           tables
                t_outtab                = it_ekko
           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_ALV_REPORT
    
    
    *&---------------------------------------------------------------------*
    *&      Form  DATA_RETRIEVAL
    *&---------------------------------------------------------------------*
    *       Retrieve data form EKPO table and populate itab it_ekko
    *----------------------------------------------------------------------*
    form data_retrieval.
    data: ld_color(1) type c.
    
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
     up to 10 rows
      from ekpo
      into table it_ekko.
    
    *Populate field with color attributes
    loop at it_ekko into wa_ekko.
    * Populate color variable with colour properties
    * Char 1 = C (This is a color property)
    * Char 2 = 3 (Color codes: 1 - 7)
    * Char 3 = Intensified on/off ( 1 or 0 )
    * Char 4 = Inverse display on/off ( 1 or 0 )
    *           i.e. wa_ekko-line_color = 'C410'
      ld_color = ld_color + 1.
    
    * Only 7 colours so need to reset color value
      if ld_color = 8.
        ld_color = 1.
      endif.
      concatenate 'C' ld_color '10' into wa_ekko-line_color.
    *  wa_ekko-line_color = 'C410'.
      modify it_ekko from wa_ekko.
    endloop.
    endform.                    " DATA_RETRIEVAL
    

    Hotspot

    REPORT zdemoab.
    
    TYPE-POOLS: slis.
    TABLES: mara.
    
    TYPES: BEGIN OF t_itab,
           matnr TYPE mara-matnr,
           mtart TYPE mara-mtart,
           END OF t_itab.
    
    DATA: itab TYPE TABLE OF t_itab,
          wa_itab like line of itab.
    
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          wa_fieldcat LIKE LINE OF i_fieldcat,
          i_layout TYPE slis_layout_alv,
          g_repid TYPE sy-repid.
    
    
    SELECT matnr mtart INTO TABLE itab FROM mara UP TO 10 ROWS.
    
    
    CLEAR: wa_fieldcat.
    wa_fieldcat-col_pos = 0.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-tabname = 'MARA'.
    wa_fieldcat-hotspot = 'X'.
    APPEND wa_fieldcat TO i_fieldcat.
    CLEAR: wa_fieldcat.
    
    wa_fieldcat-col_pos = 1.
    wa_fieldcat-fieldname = 'MTART'.
    wa_fieldcat-tabname = 'MARA'.
    APPEND wa_fieldcat TO i_fieldcat.
    CLEAR: wa_fieldcat.
    
    
    i_layout-colwidth_optimize = 'X'.
    i_layout-hotspot_fieldname = 'MATNR'.
    
    g_repid = sy-repid.
    
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program                = g_repid
       I_CALLBACK_USER_COMMAND           = 'USER_COMMAND '
       is_layout                         = i_layout
       it_fieldcat                       = i_fieldcat[]
      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.
    
    FORM user_command USING r_ucomm LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
    
    *   Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'MATNR'.
    *     To pass the material no in ME22 transaction
          READ TABLE itab INTO wa_itab INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_itab-matnr.
    *     Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'MM03'.
    *
        ENDIF.
    ENDFORM.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 06:47 AM

    Hi Poonam,

    Welcome to SDN.

    You could refer few demo programs provided in R/3.

    All programs that use ALV are having a naming convention which starts with "BCALV".

    So in SE38 transaction try giving BVALV* and click on F4. You shall get a list of programs. you could choose the program you want after reading the descriptions.

    Hope viewing these codes shall give you an exposure on ALV's.

    Reward points if this info helps,

    Kiran

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2008 at 06:58 AM

    PAGE HEADING MESSAGE-ID

    • DATE OF REPORT : 16.01.2008

    • DESC. OF REPORT : ALV to display sale order using VBAK &VBAP tables.

    • Push button to add new line item in list display

    • Layout variant for grid display

    • All Basic functionality of ALV.

    • HOT Spot on Material number to call 'MM03'.

    *EXCEPTION handling in call transection using table of type BDCMSGCOLL.

    *DOW LOAD TO EXCEL FILE ON APPLICATION SERVER

    ----


    • M O D I F I C A T I O N - L O G

    ----


    • DATE USER-NAME TRANSPORT DESCRIPTION

    *

    *

    ----


    ----


    TYPE-POOLS : SLIS. "collection of type group and type used for ALV

    TYPES: BEGIN OF STRUCT_DETAIL, "DETAIL TABLE

    VBELN TYPE VBELN_VA, "Sales doc number

    POSNR TYPE POSNR_VA, "Line item number

    MATNR TYPE MATNR, "Material number

    CHARG TYPE CHARG_D, "Batch number

    MEINS TYPE MEINS, "UOM

    ARKTX TYPE ARKTX, "Description

    KWMENG TYPE KWMENG, "Quantity

    END OF STRUCT_DETAIL.

    TYPES: BEGIN OF STRUCT_HEADER, "HEADER TABLE

    VBELN TYPE VBELN_VA, "Sales doc number

    ERNAM TYPE ERNAM, "Name of creator

    ERDAT TYPE ERDAT, "DOC

    AUART TYPE AUART, "Doc type

    VKORG TYPE VKORG, "Sale org

    NETWR TYPE NETWR_AK, "Net value

    KUNNR TYPE KUNAG, "Sold to party

    WAERK TYPE WAERK, "Currency

    SPART TYPE SPART, "Division

    VTWEG TYPE VTWEG, "Distribution channel

    VBTYP TYPE VBTYP, "SD type

    END OF STRUCT_HEADER.

    TYPES: BEGIN OF STRUCT_HEAD_DETAIL, " FINAL TABLE

    VBELN TYPE VBELN_VA,

    ERNAM TYPE ERNAM,

    ERDAT TYPE ERDAT,

    AUART TYPE AUART,

    VKORG TYPE VKORG,

    NETWR TYPE NETWR_AK,

    KUNNR TYPE KUNAG,

    WAERK TYPE WAERK,

    SPART TYPE SPART,

    VTWEG TYPE VTWEG,

    VBTYP TYPE VBTYP,

    POSNR TYPE POSNR_VA,

    MATNR TYPE MATNR,

    CHARG TYPE CHARG_D,

    MEINS TYPE MEINS,

    ARKTX TYPE ARKTX,

    KWMENG type KWMENG,

    V_BOX(1) TYPE C,

    V_LIGHTS(4) TYPE C,

    END OF STRUCT_HEAD_DETAIL.

    TYPES : HEADER_TYPE(10) TYPE C.

    *work areas

    DATA: WA_HEADER TYPE STRUCT_HEADER. "for header table

    DATA: WA_DETAIL TYPE STRUCT_DETAIL. "for detail table

    DATA: WA_HEAD_DETAIL TYPE STRUCT_HEAD_DETAIL. "for final table

    *internal tables

    DATA: IT_HEADER TYPE STANDARD TABLE OF STRUCT_HEADER. " header table

    DATA: IT_DETAIL TYPE STANDARD TABLE OF STRUCT_DETAIL. " detail table

    DATA: IT_HEAD_DETAIL TYPE STANDARD TABLE OF STRUCT_HEAD_DETAIL.

    "final table

    DATA : IT_HEADER_NAME TYPE STANDARD TABLE OF HEADER_TYPE.

    "FIELD NAME TABLE

    *work area &internal tables for ALV

    "layout work area

    DATA WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

    " Structure to display variants

    DATA : IT_VARIANT LIKE DISVARIANT,

    IT_VARIANT1 LIKE DISVARIANT.

    "field catlog table

    DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

    "list header table

    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

    "Event table

    DATA: IT_EVENTCAT TYPE SLIS_T_EVENT.

    "Sort table

    DATA: IT_SORTINFO TYPE SLIS_T_SORTINFO_ALV.

    *internal table for BDC data

    data : it_tab1 like bdcdata occurs 0 with header line.

    *internal table of exception handling in BDC

    data : it_tab_error like BDCMSGCOLL occurs 0 with header line.

    *VARIABLES

    DATA : V_PROGNAME LIKE SY-REPID. "Program name

    DATA: V_FLAG TYPE I VALUE '0'. "Temp variable

    DATA: V_KWMENG(15) type c. "Temp variable for quantity

    DATA: V_Path type string. "Temp variable for quantity

    *selection screen

    "VBELN & ERDAT

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

    SELECT-OPTIONS: S_VBELN FOR WA_HEADER-VBELN OBLIGATORY.

    SELECT-OPTIONS: S_DOC FOR WA_HEADER-ERDAT.

    SELECTION-SCREEN END OF BLOCK B1 .

    "VARIANT

    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-006.

    PARAMETERS: P_VAR TYPE SLIS_VARI.

    SELECTION-SCREEN END OF BLOCK B3.

    "RADIO BUTTON for report display & DOWNload & FOR Both

    SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-004.

    PARAMETERS: P_DOWN RADIOBUTTON GROUP RAD2 USER-COMMAND AB,

    P_REPORT RADIOBUTTON GROUP RAD2,

    P_DW_RP RADIOBUTTON GROUP RAD2 .

    SELECTION-SCREEN END OF BLOCK B4.

    "Radio button for list and grid Selection

    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

    PARAMETERS: P_GRID RADIOBUTTON GROUP RAD1

    DEFAULT 'X' ,

    P_LIST RADIOBUTTON GROUP RAD1 .

    SELECTION-SCREEN END OF BLOCK B2.

    "FILE PATH

    SELECTION-SCREEN BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-007.

    PARAMETERS: P_PATH(128) type C modif id PTH default '.\gaurav'.

    SELECTION-SCREEN END OF BLOCK B5.

    INITIALIZATION.

    V_PROGNAME = SY-REPID.

    • Display default variant using FM REUSE_ALV_VARIANT_DEFAULT_GET

    PERFORM DEFAULT_VARIANT.

    perform HEADER_NAME.

    AT SELECTION-SCREEN OUTPUT.

    if P_report = 'X'.

    loop at screen.

    if screen-group1 = 'PTH'.

    screen-active = 0.

    screen-input = 0.

    screen-invisible = 1.

    screen-required = 0.

    modify screen.

    clear screen.

    endif.

    endloop.

    ELSEif P_DOwn = 'X' or P_dw_rp = 'X'.

    loop at screen.

    if screen-group1 = 'PTH'.

    screen-active = 1.

    screen-input = 1.

    screen-output = 1.

    screen-invisible = 0.

    *screen-required = 1.

    modify screen.

    clear screen.

    endif.

    endloop.

    endif.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PATH.

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    PROGRAM_NAME = SYST-CPROG

    DYNPRO_NUMBER = SYST-DYNNR

    FIELD_NAME = ' '

    IMPORTING

    FILE_NAME = P_PATH.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.

    • Display a list of various variants of the report when the

    • user presses F4 key in the variant field

    PERFORM VARIANT_F4. "USING FM REUSE_ALV_VARIANT_F4

    ******AT SELECTION-SCREEN ON RADIOBUTTON GROUP RAD2.

    *******.

    AT SELECTION-SCREEN.

    *val....1 Variant check

    • Once the user has entered variant, check about its existence

    PERFORM CHECK_PVAR. "Using FM REUSE_ALV_VARIANT_EXISTENCE

    *val....2 Sd do not exists

    SELECT SINGLE VBELN INTO WA_HEADER-VBELN FROM VBAK WHERE VBELN IN

    S_VBELN.

    IF SY-SUBRC <> 0.

    MESSAGE E010 WITH TEXT-010.

    ENDIF.

    *val.....3 Date of creation check

    LOOP AT S_DOC.

    IF S_DOC-LOW > SY-DATUM OR S_DOC-HIGH > SY-DATUM.

    MESSAGE E011 WITH TEXT-011.

    ENDIF.

    ENDLOOP.

    *VAL....4

    if P_DOWN = 'X' AND P_PATH is initial.

    MESSAGE E011 WITH TEXT-011.

    endif.

    if P_DW_RP = 'X' AND P_path is initial.

    MESSAGE E011 WITH TEXT-011.

    endif.

    START-OF-SELECTION.

    perform IT_TAB_POPULATE.

    END-OF-SELECTION.

    if P_down = CC_X. "check for radio button group RAD2

    if sy-BATCH = ' '. "Background processing check

    perform Zf_DOWNLOAD.

    else.

    message E018 with TEXT-018.

    endif.

    elseif P_REPORT = CC_X.

    perform ZF_report.

    elseif P_DW_Rp = CC_X.

    perform ZF_report.

    if sy-BATCH = ' '. "Background processing check

    perform Zf_DOWNLOAD.

    else.

    message E018 with TEXT-018.

    endif.

    endif.

    ************************************************************************

    *****

    *FORM'S FOR EACH PERFORM

    ************************************************************************

    ****

    &----


    *& Form zf_build_fieldcat

    &----


    • text

    ----


    • -->P_IT_FIELDCAT text

    ----


    FORM ZF_BUILD_FIELDCAT USING P_IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV. "local work area

    CLEAR L_FIELDCAT.

    *VBELN SALES DOCUMENT NUMBER

    L_FIELDCAT-COL_POS = CI_1." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-079. "VBELN

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = CC_X." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = CC_x." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-020. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-021. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-023. " short key word

    L_FIELDCAT-OUTPUTLEN = 10.

    L_FIELDCAT-REF_FIELDNAME = TEXT-079.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *POSNR LINE ITEM NUMBER

    L_FIELDCAT-COL_POS = CI_2." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-078. "POSNR

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = CC_X. " column with key-color

    L_FIELDCAT-JUST = 'L'. " (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = 'X'. " leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-024. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-025. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-026. " short key word

    L_FIELDCAT-OUTPUTLEN = 6.

    L_FIELDCAT-REF_FIELDNAME = TEXT-078.

    L_FIELDCAT-REF_TABNAME = TEXT-081. "IT_DETAIL

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *ERDAT DATE OF CREATION

    L_FIELDCAT-COL_POS = CI_3." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-077. "ERDAT

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '. " column with key-color

    L_FIELDCAT-JUST = 'L'. " (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '. " leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-027." long key word

    L_FIELDCAT-SELTEXT_M = TEXT-028. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-029. " short key word

    L_FIELDCAT-OUTPUTLEN = 10.

    L_FIELDCAT-REF_FIELDNAME = TEXT-077.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *VKORG SALES ORG.

    L_FIELDCAT-COL_POS = CI_4." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-076. "VKORG

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '. " column with key-color

    L_FIELDCAT-JUST = 'L'. " (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '. " leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-030. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-031. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-032. " short key word

    L_FIELDCAT-OUTPUTLEN = 4.

    L_FIELDCAT-REF_FIELDNAME = TEXT-076.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *KUNNR SOLD TO PARTY

    L_FIELDCAT-COL_POS = CI_5." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-075. "KUNNR

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-033. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-034. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-035. " short key word

    L_FIELDCAT-OUTPUTLEN = 10.

    L_FIELDCAT-REF_FIELDNAME = TEXT-075.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *ERNAM NAME OF CONTACT PERSON

    L_FIELDCAT-COL_POS = CI_6." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-074. "ERNAM

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-036. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-037. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-038. " short key word

    L_FIELDCAT-OUTPUTLEN = 12.

    L_FIELDCAT-REF_FIELDNAME = TEXT-074.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *AUART DOCUMENT TYPE

    L_FIELDCAT-COL_POS = CI_7." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-073. "AUART

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-039. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-040. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-041. " short key word

    L_FIELDCAT-OUTPUTLEN = 4.

    L_FIELDCAT-REF_FIELDNAME = TEXT-073.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *WAERK CURRENCY

    L_FIELDCAT-COL_POS = CI_8." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-072. "WEARK

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'R'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-042. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-043. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-044. " short key word

    L_FIELDCAT-OUTPUTLEN = 5.

    L_FIELDCAT-REF_FIELDNAME = TEXT-072.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *VTWEG DISTRIBUTION CHANNEL

    L_FIELDCAT-COL_POS = CI_9." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-071. "VTWEG

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-045. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-046. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-047. " short key word

    L_FIELDCAT-OUTPUTLEN = 2.

    L_FIELDCAT-REF_FIELDNAME = TEXT-071.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *VBTYP SALE DOCUMENT CATEGORY

    L_FIELDCAT-COL_POS = CI_10." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-070. "VBTYP

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-048. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-049. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-050. " short key word

    L_FIELDCAT-OUTPUTLEN = 1.

    L_FIELDCAT-REF_FIELDNAME = TEXT-070.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *SPART SALES DIVISION

    L_FIELDCAT-COL_POS = CI_11." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-069. "SPART

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-051. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-052. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-053. " short key word

    L_FIELDCAT-OUTPUTLEN = 2.

    L_FIELDCAT-REF_FIELDNAME = TEXT-069.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *MATNR MATERIAL NUMBER

    L_FIELDCAT-COL_POS = CI_12." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-068. "MATNR

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = 'X'." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-054. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-055. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-056. " short key word

    L_FIELDCAT-OUTPUTLEN = 18.

    L_FIELDCAT-REF_FIELDNAME = TEXT-068.

    L_FIELDCAT-REF_TABNAME = TEXT-081. "IT_DETAIL

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    L_FIELDCAT-HOTSPOT = 'X' . " hotspot

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *CHARG BATCH NUMBER

    L_FIELDCAT-COL_POS = CI_13." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-067. "CHARG

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-057. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-057. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-057. " short key word

    L_FIELDCAT-OUTPUTLEN = 10.

    L_FIELDCAT-REF_FIELDNAME = TEXT-067.

    L_FIELDCAT-REF_TABNAME = TEXT-081. "IT_DETAIL

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *MEINS UNIT OF MEASUREMENT

    L_FIELDCAT-COL_POS = CI_14." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-066. "MEINS

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'R'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-058. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-059. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-059. " short key word

    L_FIELDCAT-OUTPUTLEN = 3.

    L_FIELDCAT-REF_FIELDNAME = TEXT-066.

    L_FIELDCAT-REF_TABNAME = TEXT-081. "IT_DETAIL

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *ARKTX MATERIAL DESCRIPTION

    L_FIELDCAT-COL_POS = CI_15." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-065. "ARKTX

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'L'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-060. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-060. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-061. " short key word

    L_FIELDCAT-INTLEN = 40.

    L_FIELDCAT-REF_FIELDNAME = TEXT-065.

    L_FIELDCAT-REF_TABNAME = TEXT-081. "IT_DETAL

    L_FIELDCAT-NO_SUM = 'X'. " do not sum up

    L_FIELDCAT-OUTPUTLEN = 40.

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    *NETWR NET VALUE

    L_FIELDCAT-COL_POS = '16'." position of the column

    L_FIELDCAT-FIELDNAME = TEXT-064. "NETWR

    L_FIELDCAT-TABNAME = TEXT-082. "IT_HEAD_DETAIL

    L_FIELDCAT-KEY = ' '." column with key-color

    L_FIELDCAT-JUST = 'R'." (R)ight (L)eft (C)ent.

    L_FIELDCAT-LZERO = ' '." leading zero

    L_FIELDCAT-SELTEXT_L = TEXT-062. " long key word

    L_FIELDCAT-SELTEXT_M = TEXT-063. " middle key word

    L_FIELDCAT-SELTEXT_S = TEXT-064. " short key word

    L_FIELDCAT-OUTPUTLEN = 15.

    L_FIELDCAT-REF_FIELDNAME = TEXT-064.

    L_FIELDCAT-REF_TABNAME = TEXT-080. "IT_HEADER

    L_FIELDCAT-DO_SUM = 'X'.

    L_FIELDCAT-EDIT = 'X'.

    L_FIELDCAT-INPUT = 'X'.

    APPEND L_FIELDCAT TO P_IT_FIELDCAT.

    CLEAR L_FIELDCAT.

    ENDFORM. " zf_build_fieldcat

    &----


    *& Form zf_build_listheader

    &----


    • text

    ----


    • -->P_IT_LISTHEADER text

    ----


    FORM ZF_BUILD_LISTHEADER USING P_IT_LISTHEADER TYPE

    SLIS_T_LISTHEADER.

    DATA: L_LISTHEADER TYPE SLIS_LISTHEADER.

    CLEAR L_LISTHEADER.

    L_LISTHEADER-TYP = 'H'. "Header

    L_LISTHEADER-INFO = TEXT-003.

    APPEND L_LISTHEADER TO P_IT_LISTHEADER.

    CLEAR L_LISTHEADER.

    L_LISTHEADER-TYP = 'H'. "Header<BOLD HEADING>

    L_LISTHEADER-INFO = TEXT-005.

    APPEND L_LISTHEADER TO P_IT_LISTHEADER.

    CLEAR L_LISTHEADER.

    L_LISTHEADER-TYP = 'S'. "selection

    L_LISTHEADER-KEY = TEXT-008.

    L_LISTHEADER-INFO = SY-DATUM.

    APPEND L_LISTHEADER TO P_IT_LISTHEADER.

    CLEAR L_LISTHEADER.

    L_LISTHEADER-TYP = 'A'. " Action<italics>

    L_LISTHEADER-INFO = TEXT-015.

    APPEND L_LISTHEADER TO P_IT_LISTHEADER.

    ENDFORM. " zf_build_listheader

    &----


    *& Form zf_layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM ZF_LAYOUT .

    CLEAR WA_LAYOUT.

    WA_LAYOUT-ZEBRA = 'X'.

    WA_LAYOUT-LIGHTS_FIELDNAME = 'V_LIGHTS'.

    WA_LAYOUT-LIGHTS_TABNAME = 'IT_HEAD_DETAIL'.

    WA_LAYOUT-BOX_FIELDNAME = 'V_BOX'.

    WA_LAYOUT-BOX_TABNAME = 'IT_HEAD_DETAIL'.

    wa_layout-totals_text = 'Total'.

    wa_layout-subtotals_text = 'Sub'.

    ENDFORM. " zf_layout

    &----


    *& Form zf_eventcat

    &----


    • text

    ----


    • -->P_IT_EVENTCAT text

    ----


    FORM ZF_EVENTCAT USING P_IT_EVENTCAT TYPE SLIS_T_EVENT.

    DATA: L_EVENTCAT TYPE SLIS_ALV_EVENT.

    CLEAR L_EVENTCAT.

    *Get all the events using function module <reuse_alv_events_get>.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = P_IT_EVENTCAT

    EXCEPTIONS

    LIST_TYPE_WRONG = 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.

    *_______________________________________________________________________

    • TOP-OF-PAGE FORM NAME

    CLEAR L_EVENTCAT.

    READ TABLE P_IT_EVENTCAT INTO L_EVENTCAT WITH KEY

    NAME = SLIS_EV_TOP_OF_PAGE.

    IF SY-SUBRC = 0.

    MOVE 'ZF_TOP_OF_PAGE' TO L_EVENTCAT-FORM.

    MODIFY P_IT_EVENTCAT FROM L_EVENTCAT INDEX SY-TABIX

    TRANSPORTING FORM.

    ENDIF.

    • PF_STATUS_SET FORM NAME

    CLEAR L_EVENTCAT.

    READ TABLE P_IT_EVENTCAT INTO L_EVENTCAT WITH KEY

    NAME = SLIS_EV_PF_STATUS_SET.

    IF SY-SUBRC = 0.

    MOVE 'ZF_PF_STATUS_SET' TO L_EVENTCAT-FORM.

    MODIFY P_IT_EVENTCAT FROM L_EVENTCAT INDEX SY-TABIX

    TRANSPORTING FORM.

    ENDIF.

    • USER_COMMAND FORM NAME

    CLEAR L_EVENTCAT.

    READ TABLE P_IT_EVENTCAT INTO L_EVENTCAT WITH KEY

    NAME = SLIS_EV_USER_COMMAND. "

    IF SY-SUBRC = 0.

    MOVE 'ZF_USER_COMMAND' TO L_EVENTCAT-FORM.

    MODIFY P_IT_EVENTCAT FROM L_EVENTCAT INDEX SY-TABIX

    TRANSPORTING FORM.

    ENDIF.

    ENDFORM. " zf_eventcat

    *top of page event form

    FORM ZF_TOP_OF_PAGE.

    *This FM is responsible for formatting the header information

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    I_LOGO = 'ENJOYSAP_LOGO'

    • I_END_OF_LIST_GRID =

    • I_ALV_FORM =

    .

    ENDFORM. "TOP-OF-PAGE

    *set pf status form

    FORM ZF_PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB.

    if p_list = 'X'.

    SET PF-STATUS 'ALV_MENU_GAURAV2'.

    else.

    SET PF-STATUS 'ALV_MENU_GAURAV1'.

    endif.

    ENDFORM. "SET_PF_STATUS

    *set user command form

    FORM ZF_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE

    SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&REFRESH'.

    WHEN '&DISP'. "for display

    LOOP AT IT_HEAD_DETAIL INTO WA_HEAD_DETAIL WHERE V_BOX = CC_X.

    V_FLAG = V_FLAG + 1.

    ENDLOOP.

    IF V_FLAG = 1.

    READ TABLE IT_HEAD_DETAIL INTO WA_HEAD_DETAIL WITH KEY V_BOX =

    CC_X.

    IF SY-SUBRC = 0.

    SET PARAMETER ID 'AUN' FIELD WA_HEAD_DETAIL-VBELN.

    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

    CLEAR V_FLAG.

    ENDIF.

    ELSE.

    CLEAR V_FLAG.

    MESSAGE E012 WITH TEXT-012.

    ENDIF.

    WHEN '&ITM'. "FOR line item creation

    loop at it_head_detail into wa_head_detail where v_box = CC_X.

    v_flag = v_flag + 1.

    endloop.

    if v_flag = 1.

    read table it_head_detail into wa_head_detail with key v_box =

    CC_X TRANSPORTING all fields.

    v_kwmeng = wa_head_detail-kwmeng.

    if sy-subrc = 0.

    perform z11_bdc_va02.

    else.

    message I013 with TEXT-013.

    endif.

    else.

    clear v_flag.

    message E012 with TEXT-012.

    endif.

    when '&IC1'. "for hotspot

    if rs_selfield-fieldname = 'MATNR'.

    set parameter id 'MAT' field rs_selfield-value.

    call transaction 'MM03' and skip first screen.

    endif.

    WHEN '&F03'.

    LEAVE PROGRAM.

    WHEN '&F15'.

    LEAVE PROGRAM.

    WHEN '&F12'.

    LEAVE PROGRAM.

    ENDCASE.

    ENDFORM. " USER_COMMAND

    &----


    *& Form zf_display_alv_list

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM ZF_DISPLAY_ALV_LIST .

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = V_PROGNAME

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    • I_STRUCTURE_NAME =

    IS_LAYOUT = WA_LAYOUT

    IT_FIELDCAT = IT_FIELDCAT

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    IT_SORT = IT_SORTINFO

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = 'A'

    • IS_VARIANT =

    IT_EVENTS = IT_EVENTCAT

    • 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

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = IT_HEAD_DETAIL

    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. " zf_display_alv_list

    &----


    *& Form ZF_DISPLAY_ALV_GRID

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM ZF_DISPLAY_ALV_GRID .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = V_PROGNAME

    I_CALLBACK_PF_STATUS_SET = 'ZF_PF_STATUS_SET'

    I_CALLBACK_USER_COMMAND = 'ZF_USER_COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'ZF_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_FIELDCAT

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    IT_SORT = IT_SORTINFO

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    I_SAVE = 'A'

    IS_VARIANT = IT_VARIANT1

    IT_EVENTS = IT_EVENTCAT

    • 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

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • I_HTML_HEIGHT_TOP =

    • I_HTML_HEIGHT_END =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = IT_HEAD_DETAIL

    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. " ZF_DISPLAY_ALV_GRID

    &----


    *& Form ZF_MODIFY_LIGHTS

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM ZF_MODIFY_LIGHTS .

    LOOP AT IT_HEAD_DETAIL INTO WA_HEAD_DETAIL.

    IF WA_HEAD_DETAIL-NETWR >= 10000.

    WA_HEAD_DETAIL-V_LIGHTS = '3'. "LIGTH = GREEN.

    ELSEIF WA_HEAD_DETAIL-NETWR > 5000 AND WA_HEAD_DETAIL-NETWR < 10000.

    WA_HEAD_DETAIL-V_LIGHTS = '2'. "LIGHT = YELLOW.

    ELSE.

    WA_HEAD_DETAIL-V_LIGHTS = '1'. "LIGHT = RED.

    ENDIF.

    MODIFY IT_HEAD_DETAIL FROM WA_HEAD_DETAIL TRANSPORTING V_LIGHTS.

    ENDLOOP.

    ENDFORM. " ZF_MODIFY_LIGHTS

    &----


    *& Form ZF_SORTING

    &----


    • text

    ----


    • -->P_IT_SORTINFO text

    ----


    FORM ZF_SORTING USING P_IT_SORTINFO TYPE SLIS_T_SORTINFO_ALV.

    DATA L_SORTINFO TYPE SLIS_SORTINFO_ALV.

    CLEAR L_SORTINFO.

    L_SORTINFO-SPOS = '1'.

    L_SORTINFO-FIELDNAME = 'VBELN'.

    L_SORTINFO-TABNAME = 'IT_HEAD_DETAIL'.

    L_SORTINFO-UP = 'X'.

    L_SORTINFO-GROUP = '*'. "DONT REPEAT COMMON ITEM

    • L_SORTINFO-SUBTOT = 'X'.

    APPEND L_SORTINFO TO P_IT_SORTINFO.

    ENDFORM. " ZF_SORTING

    &----


    *& Form DEFAULT_VARIANT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DEFAULT_VARIANT .

    IT_VARIANT1-REPORT = SY-REPID.

    • Search default variant for the report

    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

    EXPORTING

    I_SAVE = 'A'

    CHANGING

    CS_VARIANT = IT_VARIANT1

    EXCEPTIONS

    WRONG_INPUT = 1

    NOT_FOUND = 2

    PROGRAM_ERROR = 3

    OTHERS = 4.

    IF SY-SUBRC = 0.

    P_VAR = IT_VARIANT1-VARIANT.

    ELSE.

    P_VAR = '/DEFAULT1'.

    ENDIF.

    ENDFORM. " DEFAULT_VARIANT

    &----


    *& Form CHECK_PVAR

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM CHECK_PVAR .

    IF NOT P_VAR IS INITIAL.

    IT_VARIANT-REPORT = SY-REPID.

    IT_VARIANT-VARIANT = P_VAR.

    *FM to check existance of the variant

    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'

    EXPORTING

    I_SAVE = 'A'

    CHANGING

    CS_VARIANT = IT_VARIANT

    EXCEPTIONS

    WRONG_INPUT = 1

    NOT_FOUND = 2

    PROGRAM_ERROR = 3

    OTHERS = 4.

    IF SY-SUBRC = 0.

    CLEAR IT_VARIANT1.

    MOVE P_VAR TO IT_VARIANT1-VARIANT.

    MOVE SY-REPID TO IT_VARIANT1-REPORT.

    ELSE.

    MESSAGE E020 WITH TEXT-009.

    ENDIF.

    ELSE.

    CLEAR IT_VARIANT.

    ENDIF.

    ENDFORM. " CHECK_PVAR

    &----


    *& Form VARIANT_F4

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM VARIANT_F4 .

    IT_VARIANT-REPORT = SY-REPID.

    • Utilising the name of the report , this function module will

    • search for a list of variants and will fetch the selected one into

    • the parameter field for variants

    CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

    EXPORTING

    IS_VARIANT = IT_VARIANT

    • I_TABNAME_HEADER =

    • I_TABNAME_ITEM =

    • IT_DEFAULT_FIELDCAT =

    I_SAVE = 'A'

    I_DISPLAY_VIA_GRID = 'X'

    IMPORTING

    • E_EXIT =

    ES_VARIANT = IT_VARIANT1

    EXCEPTIONS

    NOT_FOUND = 1

    PROGRAM_ERROR = 2

    OTHERS = 3 .

    IF SY-SUBRC = 0.

    P_VAR = IT_VARIANT1-VARIANT.

    ELSE.

    CLEAR IT_VARIANT1.

    ENDIF.

    ENDFORM. " VARIANT_F4

    &----


    *& Form z11_bdc_va02

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM z11_bdc_va02 .

    *COVER 1

    perform bdc_dynpro using 'SAPMV45A' '0102'.

    perform bdc_field using 'BDC_CURSOR'

    'VBAK-VBELN'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'VBAK-VBELN'

    wa_head_detail-vbeln.

    *COVER 2

    perform bdc_dynpro using 'SAPMV45A' '4001'.

    perform bdc_field using 'BDC_OKCODE'

    '=T\03'.

    perform bdc_field using 'BDC_CURSOR'

    'RV45A-MABNR(01)'.

    *COVER 3

    perform bdc_dynpro using 'SAPMV45A' '4001'.

    perform bdc_field using 'BDC_OKCODE'

    '=ITNE'.

    perform bdc_field using 'BDC_CURSOR'

    'RV45A-MABNR(01)'.

    *COVER 4

    perform bdc_dynpro using 'SAPMV45A' '4001'.

    perform bdc_field using 'BDC_OKCODE'

    '=SICH'.

    perform bdc_field using 'BDC_CURSOR'

    'RV45A-KWMENG'.

    perform bdc_field using 'VBAP-MATNR'

    wa_head_detail-matnr.

    perform bdc_field using 'RV45A-KWMENG'

    v_kwmeng.

    perform bdc_field using 'VBAP-VRKME'

    wa_head_detail-meins.

    *COVER 5

    perform bdc_dynpro using 'SAPLSPO2' '0101'.

    perform bdc_field using 'BDC_OKCODE'

    '=OPT1'.

    call transaction 'VA02' using it_tab1 mode 'A' UPDATE 'S' MESSAGES INTO

    IT_TAB_ERROR.

    "CAlling transaction with all screen

    Loop at it_tab_error.

    if it_tab_ERROR-MSGTYP = 'E' .

    clear v_flag.

    message I014 with TEXT-014.

    else.

    clear v_flag.

    message I019 with TEXT-019.

    endif.

    endloop.

    refresh it_tab1.

    clear V_KWMENG.

    ENDFORM. " z11_bdc_va02

    *&----


    *

    *& Form bdc_dynpro

    *&----


    *

    • text

    *----


    *

    • -->P_2128 text

    • -->P_2129 text

    *----


    *

    FORM bdc_dynpro USING PROGRAM

    DYNPRO.

    CLEAR it_tab1.

    it_tab1-PROGRAM = PROGRAM.

    it_tab1-DYNPRO = DYNPRO.

    it_tab1-DYNBEGIN = 'X'.

    APPEND it_tab1.

    ENDFORM. " bdc_dynpro

    *&----


    *

    *& Form bdc_field

    *&----


    *

    • text

    *----


    *

    • -->P_2133 text

    • -->P_WA_HEAD_DETAIL_VBELN text

    *----


    *

    FORM bdc_field USING FNAM FVAL.

    IF not FVAL is initial.

    CLEAR it_tab1.

    it_tab1-FNAM = FNAM.

    move Fval to it_tab1-Fval.

    APPEND it_tab1.

    ENDIF.

    ENDFORM. " bdc_field

    &----


    *& Form Zf_DOWNLOAD

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form Zf_DOWNLOAD .

    V_path = P_PAth.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    • BIN_FILESIZE =

    filename = V_PATH

    FILETYPE = 'DAT'

    • APPEND = ' '

    • WRITE_FIELD_SEPARATOR = ' '

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • DAT_MODE = ' '

    • CONFIRM_OVERWRITE = ' '

    • NO_AUTH_CHECK = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • WRITE_BOM = ' '

    • TRUNC_TRAILING_BLANKS_EOL = 'X'

    • WK1_N_FORMAT = ' '

    • WK1_N_SIZE = ' '

    • WK1_T_FORMAT = ' '

    • WK1_T_SIZE = ' '

    • IMPORTING

    • FILELENGTH =

    tables

    data_tab = IT_HEAD_DETAIL

    FIELDNAMES = IT_HEADER_NAME

    EXCEPTIONS

    FILE_WRITE_ERROR = 1

    NO_BATCH = 2

    GUI_REFUSE_FILETRANSFER = 3

    INVALID_TYPE = 4

    NO_AUTHORITY = 5

    UNKNOWN_ERROR = 6

    HEADER_NOT_ALLOWED = 7

    SEPARATOR_NOT_ALLOWED = 8

    FILESIZE_NOT_ALLOWED = 9

    HEADER_TOO_LONG = 10

    DP_ERROR_CREATE = 11

    DP_ERROR_SEND = 12

    DP_ERROR_WRITE = 13

    UNKNOWN_DP_ERROR = 14

    ACCESS_DENIED = 15

    DP_OUT_OF_MEMORY = 16

    DISK_FULL = 17

    DP_TIMEOUT = 18

    FILE_NOT_FOUND = 19

    DATAPROVIDER_EXCEPTION = 20

    CONTROL_FLUSH_ERROR = 21

    OTHERS = 22

    .

    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. " Zf_DOWNLOAD

    &----


    *& Form ZF_report

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form ZF_report .

    IF NOT IT_HEAD_DETAIL[] IS INITIAL.

    *FIELD CATLOG

    PERFORM ZF_BUILD_FIELDCAT USING IT_FIELDCAT.

    *To set Lights for Sales document

    PERFORM ZF_MODIFY_LIGHTS.

    *LIST HEADER HEADER INFORMATION

    PERFORM ZF_BUILD_LISTHEADER USING IT_LISTHEADER.

    *ASSIGN FORM NAME TO EACH EVENT GOT THROUGH 'FM'.

    PERFORM ZF_EVENTCAT USING IT_EVENTCAT.

    • PREPARE DEFAULT SORTING FOR MAIN.

    PERFORM ZF_SORTING USING IT_SORTINFO.

    *layout

    PERFORM ZF_LAYOUT.

    *RADIO BUTTON CHECK

    IF P_LIST = 'X'. "FOR LIST

    *PREPARE DISPLAY ALV LIST.

    PERFORM ZF_DISPLAY_ALV_LIST.

    ELSE. "FOR GRID

    *PREPARE DISPLAY ALV GRID.

    PERFORM ZF_DISPLAY_ALV_GRID.

    ENDIF.

    ENDIF.

    endform. " ZF_report

    &----


    *& Form IT_TAB_POPULATE

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form IT_TAB_POPULATE .

    *populating header internal table....

    SELECT VBELN

    ERNAM

    ERDAT

    AUART

    VKORG

    NETWR

    KUNNR

    WAERK

    SPART

    VTWEG

    VBTYP INTO TABLE IT_HEADER

    FROM VBAK

    WHERE VBELN IN S_VBELN

    AND ERDAT IN S_DOC.

    IF SY-SUBRC = 0.

    SORT IT_HEADER BY VBELN.

    ENDIF.

    IF NOT IT_HEADER[] IS INITIAL. "if header table is not empty

    *populating detail internal table...

    SELECT VBELN

    POSNR

    MATNR

    CHARG

    MEINS

    ARKTX

    KWMENG INTO TABLE IT_DETAIL

    FROM VBAP

    FOR ALL ENTRIES IN IT_HEADER

    WHERE VBELN = IT_HEADER-VBELN.

    IF SY-SUBRC = 0.

    SORT IT_DETAIL BY VBELN POSNR.

    ENDIF.

    ENDIF.

    *populating final table with header and detail info...

    LOOP AT IT_DETAIL INTO WA_DETAIL.

    WA_HEAD_DETAIL-VBELN = WA_DETAIL-VBELN.

    "MOVING data from detail table to final table

    WA_HEAD_DETAIL-POSNR = WA_DETAIL-POSNR.

    WA_HEAD_DETAIL-MATNR = WA_DETAIL-MATNR.

    WA_HEAD_DETAIL-CHARG = WA_DETAIL-CHARG.

    WA_HEAD_DETAIL-MEINS = WA_DETAIL-MEINS.

    WA_HEAD_DETAIL-ARKTX = WA_DETAIL-ARKTX.

    WA_HEAD_DETAIL-KWMENG = WA_DETAIL-KWMENG.

    AT NEW VBELN.

    READ TABLE IT_HEADER INTO WA_HEADER WITH KEY VBELN =

    WA_DETAIL-VBELN BINARY SEARCH .

    IF SY-SUBRC = 0.

    WA_HEAD_DETAIL-VBELN = WA_HEADER-VBELN.

    "POPULATING final table with header information

    WA_HEAD_DETAIL-ERNAM = WA_HEADER-ERNAM.

    WA_HEAD_DETAIL-ERDAT = WA_HEADER-ERDAT.

    WA_HEAD_DETAIL-AUART = WA_HEADER-AUART.

    WA_HEAD_DETAIL-VKORG = WA_HEADER-VKORG.

    WA_HEAD_DETAIL-NETWR = WA_HEADER-NETWR.

    WA_HEAD_DETAIL-KUNNR = WA_HEADER-KUNNR.

    WA_HEAD_DETAIL-WAERK = WA_HEADER-WAERK.

    WA_HEAD_DETAIL-SPART = WA_HEADER-SPART.

    WA_HEAD_DETAIL-VTWEG = WA_HEADER-VTWEG.

    WA_HEAD_DETAIL-VBTYP = WA_HEADER-VBTYP.

    ENDIF.

    ENDAT.

    APPEND WA_HEAD_DETAIL TO IT_HEAD_DETAIL.

    ENDLOOP.

    endform. " IT_TAB_POPULATE

    &----


    *& Form HEADER_NAME

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form HEADER_NAME .

    *populating internal table for text heading to downloaded file

    APPEND TEXT-083 TO IT_HEADER_NAME ."SALES ORDER

    APPEND TEXT-084 TO IT_HEADER_NAME ."NAME

    APPEND TEXT-085 TO IT_HEADER_NAME ."CREATE DATE

    APPEND TEXT-086 TO IT_HEADER_NAME ."DOC type

    APPEND TEXT-087 TO IT_HEADER_NAME ."Sales org.

    APPEND TEXT-088 TO IT_HEADER_NAME ."Net Value

    APPEND TEXT-089 TO IT_HEADER_NAME ."Customer

    APPEND TEXT-090 TO IT_HEADER_NAME ."Currency

    APPEND TEXT-091 TO IT_HEADER_NAME ."Division

    APPEND TEXT-092 TO IT_HEADER_NAME ."Distribution chn

    APPEND TEXT-093 TO IT_HEADER_NAME ."DOC category

    APPEND TEXT-094 TO IT_HEADER_NAME ."Line itm

    APPEND TEXT-095 TO IT_HEADER_NAME ."Material

    APPEND TEXT-096 TO IT_HEADER_NAME ."Batch

    APPEND TEXT-097 TO IT_HEADER_NAME ."UOM

    APPEND TEXT-098 TO IT_HEADER_NAME ."Description

    APPEND TEXT-099 TO IT_HEADER_NAME ."Net price

    endform.

    REGARDS ,

    GAURAV J.

    Edited by: GAURAV on Feb 1, 2008 7:59 AM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.