Register Login

Billing Report in ALV Forrmat

Updated May 18, 2018

type-pools:slis.
TABLES :vbrk.
*********Structure declaration*******
TYPES : BEGIN OF ty_vbrk,
        vbeln TYPE vbeln_vf,  "Billing Document
        END OF ty_vbrk.

TYPES : BEGIN OF ty_vbrp,
        vbeln TYPE vbeln_vf,
        posnr TYPE posnr_vf,
        fkimg TYPE fkimg,
         delino TYPE VBELN_VON,
        delitem TYPE POSNR_VON,
        lfimg TYPE lfimg,
        vgbel TYPE vgbel,
        vgpos TYPE vgpos,
        END OF ty_vbrp.

DATA : is_vbrk TYPE ty_vbrk,
       is_vbrp TYPE ty_vbrp.

DATA:  it_vbrk TYPE STANDARD TABLE OF ty_vbrk,
       it_vbrp TYPE STANDARD TABLE OF ty_vbrp.


DATA:BILL_TOT TYPE FKIMG,
     BILL1_TOT TYPE LFIMG.

 DATA :T_FCAT TYPE SLIS_T_FIELDCAT_ALV,
       W_FCAT TYPE SLIS_FIELDCAT_ALV,
       W_LAY TYPE SLIS_LAYOUT_ALV.

*SELECTION-SCREEN DECLARATION.

SELECT-OPTIONS : s_vbeln FOR vbrk-vbeln.

START-OF-SELECTION.

  PERFORM f_fetch_data.

  PERFORM f_field_catalog.

  PERFORM f_display_data.

********To fetch the data from database*******
  FORM f_fetch_data .

  SELECT vbeln FROM vbrk INTO TABLE
             it_vbrk
    WHERE vbeln IN s_vbeln.

IF it_vbrk IS NOT INITIAL.

    SELECT vbeln posnr fkimg vgbel vgpos FROM vbrp
           INTO CORRESPONDING FIELDS OF TABLE it_vbrp
   FOR ALL ENTRIES IN it_vbrk WHERE
      vbeln = it_vbrk-vbeln.
 ENDIF.

LOOP at it_vbrp INTO is_vbrp.
  SELECT SINGLE vbelv posnv FROM vbfa INTO (is_vbrp-delino,is_vbrp-delitem)
  WHERE vbeln = is_vbrp-vbeln AND
        posnv = is_vbrp-posnr.

    MODIFY it_vbrp INDEX sy-tabix FROM is_vbrp
            TRANSPORTING delino delitem.

    SELECT SINGLE lfimg FROM LIPS INTO (is_vbrp-lfimg)
      WHERE vbeln = is_vbrp-vgbel AND
            posnr = is_vbrp-vgpos.

      MODIFY it_vbrp INDEX sy-tabix FROM is_vbrp
            TRANSPORTING lfimg.
ENDLOOP.

ENDFORM.



*&---------------------------------------------------------------------*
*&      Form  f_field_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_field_catalog .

    W_FCAT-FIELDNAME = 'VBELN'.
    W_FCAT-TABNAME = 'T_FCAT'.
    W_FCAT-COL_POS = 1.
    W_FCAT-SELTEXT_M = 'Invoice Number'.
    APPEND W_FCAT TO T_FCAT.
    CLEAR W_FCAT.

    W_FCAT-FIELDNAME = 'POSNR'.
    W_FCAT-TABNAME = 'T_FCAT'.
    W_FCAT-COL_POS = 2.
    W_FCAT-SELTEXT_M = 'Invoice Item'.
    APPEND W_FCAT TO T_FCAT.
    CLEAR W_FCAT.

    W_FCAT-FIELDNAME = 'FKIMG'.
    W_FCAT-TABNAME = 'T_FCAT'.
    W_FCAT-COL_POS = 3.
    W_FCAT-SELTEXT_M = 'Invoice Quantity'.
    APPEND W_FCAT TO T_FCAT.
    CLEAR W_FCAT.

    W_FCAT-FIELDNAME = 'DELINO'.
    W_FCAT-TABNAME = 'T_FCAT'.
    W_FCAT-COL_POS = 4.
    W_FCAT-SELTEXT_M = 'Delivery Number'.
    APPEND W_FCAT TO T_FCAT.
    CLEAR W_FCAT.

    W_FCAT-FIELDNAME = 'DELITEM'.
    W_FCAT-TABNAME = 'T_FCAT'.
    W_FCAT-COL_POS = 5.
    W_FCAT-SELTEXT_M = 'Delivery Item'.
    APPEND W_FCAT TO T_FCAT.
    CLEAR W_FCAT.

    W_FCAT-FIELDNAME = 'LFIMG'.
    W_FCAT-TABNAME = 'T_FCAT'.
    W_FCAT-COL_POS = 5.
    W_FCAT-SELTEXT_M = 'Delivery Quantity'.
    APPEND W_FCAT TO T_FCAT.
    CLEAR W_FCAT.

ENDFORM.                    " f_field_catalog


*&---------------------------------------------------------------------*
*&      Form  f_display_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_display_data .

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            = ' '
*   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                       = T_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_VBRP
* 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.                    " f_display_data


×