Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

This report will take delivery document number and delivery date from user and fetches details from delivery table and fetches

corresponding sales order details and billing details  and displays sales order details with ALV list.

Error rendering macro 'code': Invalid value specified for parameter 'lang'
REPORT SALES_ORDER_REPORT .
*"Table declarations..............................................................
TABLES: LIKP. " SD Document: Delivery Header  Data
*"Selection Screen Elements.....................................................
SELECT-OPTIONS:
S_DELDOC FOR LIKP-VBELN, " Delivery
S_DLDATE FOR LIKP-LFDAT. " Delivery Date
*"--------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified delivery header data *
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF TYPE_S_LIKP,
VBELN TYPE LIKP-VBELN, " Delivery
LFDAT TYPE LIKP-LFDAT, " Delivery Date
KUNNR TYPE LIKP-KUNNR, " Ship-to party
END OF TYPE_S_LIKP.
*"---------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified delivery item  data      *
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF TYPE_S_LIPS,
VBELN TYPE LIPS-VBELN, " Delivery
POSNR TYPE LIPS-POSNR, " Delivery Item
VGBEL TYPE LIPS-VGBEL, " Document number of the  reference document
VGPOS TYPE LIPS-VGPOS, " Item number of the reference  item
LFIMG TYPE LIPS-LFIMG, " Actual quantity delivered (insales units)
VRKME TYPE LIPS-VRKME, " Sales unit
END OF TYPE_S_LIPS.
*"--------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified data in Customer Master *
*"---------------------------------------------------------------------------------------*
TYPES :
BEGIN OF TYPE_S_KNA1,
KUNNR TYPE KNA1-KUNNR, " Customer Number 1
NAME1 TYPE KNA1-NAME1,                                      " Name 1
END OF TYPE_S_KNA1.
*" Type declarations..........................................................................
*"------------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified sales document  header data *
*"------------------------------------------------------------------------------------------------*
TYPES :
BEGIN OF TYPE_S_VBAK,
VBELN TYPE VBAK-VBELN, " Sales Document
ERDAT TYPE VBAK-ERDAT, " Date on Which Record Was  Created
AUFNR TYPE VBAK-AUFNR, " Order Number
END OF TYPE_S_VBAK.
*"----------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified sales document   item data *
*"---------------------------------------------------------------------------------------------*
TYPES :
BEGIN OF TYPE_S_VBAP,
VBELN TYPE VBAK-VBELN, " Sales Document
POSNR TYPE VBAP-POSNR, " Sales Document Item
MATNR TYPE VBAP-MATNR, " Material Number
ARKTX TYPE VBAP-ARKTX, " Short text for sales orderitem
KWMENG TYPE VBAP-KWMENG, " Cumulative Order Quantity in sales Units
VRKME TYPE VBAP-VRKME, " Sales unit
END OF TYPE_S_VBAP.
*"--------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified billing item  data                *
*"--------------------------------------------------------------------------------------------*
TYPES :
BEGIN OF TYPE_S_VBRP,
VBELN TYPE VBRP-VBELN, " Billing Document
POSNR TYPE VBRP-POSNR, " Billing item
VGBEL TYPE VBRP-VGBEL, " Document number of the reference document
VGPOS TYPE VBRP-VGPOS, " Item number of the reference item
FKLMG TYPE VBRP-FKLMG, " Billing quantity in stockkeeping unit
VRKME TYPE VBRP-VRKME, " Sales unit
END OF TYPE_S_VBRP.
*"-------------------------------------------------------------------------------------------*
* Type declaration of the structure to hold specified sales socument               *
* header,sales document item data,delivery item data,billing item data            *
*"-------------------------------------------------------------------------------------------*
TYPES:
BEGIN OF TYPE_S_ORDER,
VBELN TYPE VBAP-VBELN, " Sales Document
POSNR TYPE VBAP-POSNR, " Sales Document Item
ERDAT TYPE VBAK-ERDAT, " Date on Which Record Was Created
KUNNR TYPE LIKP-KUNNR, " Sold-to party
NAME1 TYPE KNA1-NAME1,                                      " Name 1
AUFNR TYPE VBAK-AUFNR, " Order Number
MATNR TYPE VBAP-MATNR, " Material Number
ARKTX TYPE VBAP-ARKTX, " Short text for sales orderitem
KWMENG TYPE VBAP-KWMENG, " Cumulative Order Quantity in sales Units
VRKME TYPE VBAP-VRKME, " Sales unit
VBELN1 TYPE LIPS-VBELN, " Delivery
POSNR1 TYPE LIPS-POSNR, " Delivery Item
LFIMG TYPE LIPS-LFIMG, " Actual quantity delivered in sales units
VRKME1 TYPE LIPS-VRKME, " Sales unit
VBELN2 TYPE VBRP-VBELN, " Billing Document
POSNR2 TYPE VBRP-POSNR, " Billing item
FKLMG TYPE VBRP-FKLMG, " Billing quantity in stockkeeping unit
VRKME2 TYPE VBRP-VRKME, " Sales unit
END OF TYPE_S_ORDER.
*" Data declarations......................................................................
*"-------------------------------------------------------------------------------------------*
* Work variables                                                                                                  *
*"-------------------------------------------------------------------------------------------*
DATA :
W_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER," Reference variable for
                                                                                   "container
W_GRID TYPE REF TO CL_GUI_ALV_GRID. " Reference variable for grid
*" Field String declarations..............................................................
*"------------------------------------------------------------------------------------------*
* Field string variable to hold sales socument header,sales document              *
* item data,delivery item data,billing item data,fieldcatalog,layout  record       *
*"-------------------------------------------------------------------- --------------------*
DATA :
FS_KNA1 TYPE TYPE_S_KNA1, " Holds Customer master record
FS_VBAK TYPE TYPE_S_VBAK, " Holds sales header record
FS_VBAP TYPE TYPE_S_VBAP, " Holds sales item record
FS_LIKP TYPE TYPE_S_LIKP, " Holds delivery header record
FS_LIPS TYPE TYPE_S_LIPS, " Holds delivery item record
FS_VBRP TYPE TYPE_S_VBRP, " Holds billing item record
FS_ORDER TYPE TYPE_S_ORDER, " Holds sales order record
FS_CAT TYPE LVC_S_FCAT, " Holds fieldcatalog record
FS_LAY TYPE LVC_S_LAYO. " Holds layout record
*" Internal Table declarations...........................................................
**"-----------------------------------------------------------------------------------------*
** Internal Table to hold hold sales socument header,sales document              *
* item data,delivery item data,billing item data,fieldcatalog,layout  records       *
**"-------------------------------------------------------------------------------------------*
DATA :
T_KNA1 LIKE
STANDARD TABLE
OF FS_KNA1, " Internal table to hold customer master records
T_VBAK LIKE
STANDARD TABLE
OF FS_VBAK, " Internal table to hold sales header records
T_VBAP LIKE
STANDARD TABLE
OF FS_VBAP, " Internal table to hold sales  item records
T_LIKP LIKE
STANDARD TABLE
OF FS_LIKP, " Internal table to hold delivery header records
T_LIPS LIKE
STANDARD TABLE
OF FS_LIPS, " Internal table to hold delivery item records
T_VBRP LIKE
STANDARD TABLE
OF FS_VBRP, " Internal table to hold billing  item records
T_ORDER LIKE
STANDARD TABLE
OF FS_ORDER, " Internal table to hold sales order records
T_CAT TYPE LVC_T_FCAT. " Internal table to hold field
" catalog records
*"------------------------------------------------------------------------------------------------*
* AT SELECTION-SCREEN EVENT *
*"------------------------------------------------------------------------------------------------*
AT SELECTION-SCREEN .
  PERFORM CHECK_FOR_INITIAL.
*"--------------------------------------------------------------------------------------------------*
* AT SELECTION-SCREEN ON S_DELDOC EVENT *
*"--------------------------------------------------------------------------------------------------*
AT SELECTION-SCREEN ON S_DELDOC.
  PERFORM CHECK_DELIVERY_DOCUMENT.
*"-------------------------------------------------------------------------------------------------*
* AT SELECTION-SCREEN ON S_DLDATE EVENT *
*"------------------------------------------------------------------------------------------------*
AT SELECTION-SCREEN ON S_DLDATE.
  PERFORM CHECK_DELIVERY_DATE.
*"------------------------------------------------------------------------------------------------*
* START-OF-SELECTION EVENT *
*"-------------------------------------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM DATA_SELECTION.
*&--------------------------------------------------------------------------------------------------*
*& Form DATA_SELECTION
*&---------------------------------------------------------------------*
* This subroutine is used to select required fields from sales header,
* sales item,delivery header,delivery item ,customer master tables
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*----------------------------------------------------------------------*
FORM DATA_SELECTION .
* Get delivery document number,delivery date,customer number from
* delivery header table
  SELECT VBELN " Delivery
  LFDAT " Delivery Date
  KUNNR " Customer Number 1
  FROM LIKP
  INTO TABLE T_LIKP
  WHERE VBELN IN S_DELDOC
  AND LFDAT IN S_DLDATE.
  IF SY-SUBRC EQ 0.
* Get Customer name for customer numbers from Customer master table
    SELECT KUNNR " Customer Number 1
    NAME1                                                   " Name 1
    FROM KNA1
    INTO TABLE T_KNA1
    FOR ALL ENTRIES IN T_LIKP
    WHERE KUNNR EQ T_LIKP-KUNNR.
    IF SY-SUBRC EQ 0.
* Get delivery item number,sales document number,sales item number,
* delivery quantity from delivery item table
      SELECT VBELN " Delivery
      POSNR " Delivery Item
      VGBEL " Document number of
      " reference document
      VGPOS " Item number of reference item
      LFIMG " Actual quantity delivered
      VRKME " Sales unit
      FROM LIPS
      INTO TABLE T_LIPS
      FOR ALL ENTRIES IN T_LIKP
      WHERE VBELN EQ T_LIKP-VBELN.
      IF SY-SUBRC EQ 0.
* Get sales document number,item number,material,material description,
* ordered quantity from sales item table
        SELECT VBELN " Sales Document
        POSNR " Sales Document Item
        MATNR " Material Number
        ARKTX " Short text for sales order
        " item
        KWMENG " Cumulative Order Quantity
        VRKME " Sales unit
        FROM VBAP
        INTO TABLE T_VBAP
        FOR ALL ENTRIES IN T_LIPS
        WHERE VBELN EQ T_LIPS-VGBEL
        AND POSNR EQ T_LIPS-VGPOS.
        IF SY-SUBRC EQ 0.
* Get sales document number ,created date,purchase order number from
* sales header tableSELECT vbeln " Sales Document
          ERDAT " Date on Which Record Was
          " Created
          AUFNR " Order Number
          FROM VBAK
          INTO TABLE T_VBAK
          FOR ALL ENTRIES IN T_LIPS
          WHERE VBELN EQ T_LIPS-VGBEL.
          IF SY-SUBRC EQ 0.
*             * GET BILLING DOCUMENT NUMBER,BILLING ITEM,REFERENCE DELIVERY DOCUMENT
* number,delivery item number,billing item from billing item table
            SELECT VBELN " Billing Document
            POSNR " Billing item
            VGBEL " Document number of the
            " reference document
            VGPOS " Item number of the
            " reference
            " item
            FKLMG " Billing quantity in
            " stockkeeping unit
            VRKME " Sales unit
            FROM VBRP
            INTO TABLE T_VBRP
            FOR ALL ENTRIES IN T_LIPS
            WHERE VGBEL EQ T_LIPS-VBELN
            AND VGPOS EQ T_LIPS-POSNR.
          ENDIF. " IF SY-SUBRC EQ 0
        ENDIF. " IF SY-SUBRC EQ 0
      ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
  ELSE.
* Display message if records are not found for entered values
    MESSAGE S000.
    EXIT.
  ENDIF. " IF SY-SUBRC EQ 0
* Looping Delivery item internal table to assign values to order
* internal table
  LOOP AT T_LIPS INTO FS_LIPS.
* Get delivery date and customer number for delivery document number
* from delivery header internal table
    READ TABLE T_LIKP WITH KEY VBELN = FS_LIPS-VBELN
    INTO FS_LIKP.
* Get customer name for customer number from customer master internal
* table
    IF SY-SUBRC EQ 0.
      READ TABLE T_KNA1 WITH KEY KUNNR = FS_LIKP-KUNNR
      INTO FS_KNA1.
* Get sales document number,item number,ordered quantity for delivery
* document number,item number from sales item internal table
      IF SY-SUBRC EQ 0.
        READ TABLE T_VBAP WITH KEY VBELN = FS_LIPS-VGBEL
        POSNR = FS_LIPS-VGPOS INTO FS_VBAP.
* Get goods issue date and purchase order number for sales document
* number from sales header internal table
        IF SY-SUBRC EQ 0.
          READ TABLE T_VBAK WITH KEY VBELN = FS_VBAP-VBELN INTO FS_VBAK.
          IF SY-SUBRC EQ 0.
* Get billing document number,billing item,billing quantity for delivery
* document number,delivery item number from billing item internal table
            READ TABLE T_VBRP WITH KEY VGBEL = FS_LIPS-VBELN
            VGPOS = FS_LIPS-POSNR INTO
            FS_VBRP.
* Assign sales,delivery,billing fields into respective fields of sales
* order internal table
            IF SY-SUBRC EQ 0.
              FS_ORDER-VBELN = FS_VBAP-VBELN.
              FS_ORDER-POSNR = FS_VBAP-POSNR.
              FS_ORDER-ERDAT = FS_VBAK-ERDAT.
              FS_ORDER-KUNNR = FS_LIKP-KUNNR.
              FS_ORDER-NAME1 = FS_KNA1-NAME1.
              FS_ORDER-AUFNR = FS_VBAK-AUFNR.
              FS_ORDER-MATNR = FS_VBAP-MATNR.
              FS_ORDER-ARKTX = FS_VBAP-ARKTX.
              FS_ORDER-KWMENG = FS_VBAP-KWMENG.
              FS_ORDER-VRKME = FS_VBAP-VRKME.
              FS_ORDER-VBELN1 = FS_LIPS-VBELN.
              FS_ORDER-POSNR1 = FS_LIPS-POSNR.
              FS_ORDER-LFIMG = FS_LIPS-LFIMG.
              FS_ORDER-VRKME1 = FS_LIPS-VRKME.
              FS_ORDER-VBELN2 = FS_VBRP-VBELN.
              FS_ORDER-POSNR2 = FS_VBRP-POSNR.
              FS_ORDER-FKLMG = FS_VBRP-FKLMG.
              FS_ORDER-VRKME2 = FS_VBRP-VRKME.
              APPEND FS_ORDER TO T_ORDER.
              CLEAR FS_ORDER.
            ENDIF. " IF SY-SUBRC EQ 0
          ENDIF. " IF SY-SUBRC EQ 0
        ENDIF. " IF SY-SUBRC EQ 0
      ENDIF. " IF SY-SUBRC EQ 0
    ENDIF. " IF SY-SUBRC EQ 0
  ENDLOOP. " LOOP AT T_LIPS INTO FS_LIPS
* Check if the final table is initia
  IF T_ORDER IS INITIAL.
    MESSAGE S000.
    EXIT.
  ELSE.
* Calling screen to display the sales order records
    CALL SCREEN 1500.
  ENDIF. " IF T_ORDER IS INITIAL
ENDFORM. " DATA_SELECTION
*&---------------------------------------------------------------------*
*& Form CHECK_FOR_INITIAL
*&---------------------------------------------------------------------*
* This subroutine is used to validate selection screen elements
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*----------------------------------------------------------------------*
FORM CHECK_FOR_INITIAL .
* Check if either delivery document number and delivery date is not
* entered
  IF S_DELDOC IS INITIAL AND S_DLDATE IS INITIAL.
    MESSAGE E001 DISPLAY LIKE 'S'.
  ENDIF. " IF S_DELDOC IS INITIAL AND....
ENDFORM. " CHECK_FOR_INITIAL
*&---------------------------------------------------------------------*
*& Form CHECK_DELIVERY_DOCUMENT
*&---------------------------------------------------------------------*
* This subroutine is used to perform validation on delivery document
* number
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*----------------------------------------------------------------------*
FORM CHECK_DELIVERY_DOCUMENT .
* Check if high value is entered without lowvalue
  IF S_DELDOC-LOW IS INITIAL AND S_DELDOC-HIGH IS NOT INITIAL.
    MESSAGE E004 DISPLAY LIKE 'S'.
  ELSE.
* Check if delivery document is in delivery header table
    SELECT VBELN " Sales Document
    FROM LIKP
    UP TO 1 ROWS
    INTO FS_LIKP-VBELN
    WHERE VBELN IN S_DELDOC.
    ENDSELECT.
* Displays message if there is no record for entered delivery document
* number
    IF SY-SUBRC NE 0.
      MESSAGE E002 DISPLAY LIKE 'S'.
    ENDIF. " IF SY_SUBRC NE 0
    CLEAR FS_LIKP.
  ENDIF. " IF S_DELDOC-LOW IS INITIAL...
ENDFORM. " CHECK_DELIVERY_DOCUMENT
*&---------------------------------------------------------------------*
*& Form CHECK_DELIVERY_DATE
*&---------------------------------------------------------------------*
* This subroutine is used to perform validation on goods issue date
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine
*----------------------------------------------------------------------*
FORM CHECK_DELIVERY_DATE .
* Check if high value is entered without lowvalue
  IF S_DLDATE-LOW IS INITIAL AND S_DLDATE-HIGH IS NOT INITIAL.
    MESSAGE E004 DISPLAY LIKE 'S'.
  ELSE.
* Check if delivery date is in delivery header table
    SELECT LFDAT " Date on which record is created
    FROM LIKP
    UP TO 1 ROWS
    INTO FS_LIKP-LFDAT
    WHERE LFDAT IN S_DLDATE.
    ENDSELECT.
    CLEAR FS_LIKP.
* Displays message if there is no record for entered delivery date
    IF SY-SUBRC NE 0.
      MESSAGE E003 DISPLAY LIKE 'S'.
    ENDIF. " IF SY_SUBRC NE 0
  ENDIF. " IF S_DLDATE-LOW IS INITIAL...
ENDFORM. " CHECK_DELIVERY_DATE
*&---------------------------------------------------------------------*
*& Module STATUS_1500 OUTPUT
*&---------------------------------------------------------------------*
* This module is used to hold pfstatus for the ALV list display
*----------------------------------------------------------------------*
MODULE STATUS_1500 OUTPUT.
* Holds pf-status for the screen 1500
  SET PF-STATUS 'SALES_ORDER'.
* Assigns title to the list output
  SET TITLEBAR 'SALES'.
ENDMODULE. " STATUS_1500 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1500 INPUT
*&---------------------------------------------------------------------*
* This module is used to hold user command for screen navigation
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1500 INPUT.
* Navigates screen on back,exit,return user commands
  CASE SY-UCOMM.
    WHEN 'BACK' OR '%EX' OR 'RW'.
      SET SCREEN '0'.
  ENDCASE. " CASE SY-UCOMM
ENDMODULE. " USER_COMMAND_1500 INPUT
*&---------------------------------------------------------------------*
*& Module SALES_DISPLAY OUTPUT
*&---------------------------------------------------------------------*
* This module is used to populate fieldcatalogue and layout and *
* create container and grid and call method of grid to display sales *
* order *
*----------------------------------------------------------------------*
MODULE SALES_DISPLAY OUTPUT.
* Calling subroutine to populate values into fieldcatalogue
  PERFORM POP_FCAT USING 'VBELN'(006) 'Sales Doc.'(007) '1' .
  PERFORM POP_FCAT USING 'POSNR'(008) 'Item'(009) '2' .
  PERFORM POP_FCAT USING 'ERDAT'(010) 'Goods Issue'(011) '3' .
  PERFORM POP_FCAT USING 'KUNNR'(012) 'Sold-to Party'(013) '4' .
  PERFORM POP_FCAT USING 'NAME1'(014) 'Sold-to Desciption'(015) '5' .
  PERFORM POP_FCAT USING 'AUFNR'(016) 'Purchase Order No.'(017) '6' .
  PERFORM POP_FCAT USING 'MATNR'(018) 'Material'(019) '7' .
  PERFORM POP_FCAT USING 'ARTKX'(020) 'Material Description'(021) '8'.
  PERFORM POP_FCAT USING 'KWMENG'(022) 'Ordered Quantity'(023) '9' .
  PERFORM POP_FCAT USING 'VRKME'(024) 'Sales Unit'(025) '10' .
  PERFORM POP_FCAT USING 'VBELN1'(026) 'Delivery Doc. No.'(027) '11' .
  PERFORM POP_FCAT USING 'POSNR1'(028) 'Delivery Item '(029) '12' .
  PERFORM POP_FCAT USING 'LFIMG'(030) 'Delivery Quantity'(031) '13' .
  PERFORM POP_FCAT USING 'VRKME1'(032) 'Sales Unit'(025) '14' .
  PERFORM POP_FCAT USING 'VBELN2'(033) 'Billing doc. No.'(034) '15' .
  PERFORM POP_FCAT USING 'POSNR2'(035) 'Billing Item'(036) '16' .
  PERFORM POP_FCAT USING 'FKLMG'(037) 'Billing Quantity'(038) '17' .
  PERFORM POP_FCAT USING 'VRKME2'(039) 'Sales Unit'(025) '18' .
* Assigning title of layout
  FS_LAY-GRID_TITLE = 'List to display sales order details'(040).
* Creating container for displaying records
  CREATE OBJECT W_CONTAINER
  EXPORTING
* parent =
  CONTAINER_NAME = 'CCONTAINER' .
  IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Creating grid for the container
  CREATE OBJECT W_GRID
  EXPORTING
* i_shellstyle = 0
* i_lifetime =
  I_PARENT = W_CONTAINER.
  IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF. " IF SY_SUBRC NE 0
* Calling method of grid to display table contents
  CALL METHOD W_GRID->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      I_STRUCTURE_NAME              = 'FS_ORDER'
      IS_LAYOUT                     = FS_LAY
    CHANGING
      IT_OUTTAB                     = T_ORDER
      IT_FIELDCATALOG               = T_CAT
    EXCEPTIONS
      INVALID_PARAMETER_COMBINATION = 1
      PROGRAM_ERROR                 = 2
      TOO_MANY_LINES                = 3
      OTHERS                        = 4.
  IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF. " IF SY_SUBRC NE 0
ENDMODULE. " SALES_DISPLAY OUTPUT
*&---------------------------------------------------------------------*
*& Form POP_FCAT
*&---------------------------------------------------------------------*
* This subroutine is used to populate fieldcatalogue for required
* fields
*----------------------------------------------------------------------*
* -->P_FNAME Holds fieldname
* -->P_CTEXT Holds column text
* -->P_CPOS Holds column position
*----------------------------------------------------------------------*
FORM POP_FCAT USING VALUE(P_FNAME) TYPE C
VALUE(P_CTEXT) TYPE C
VALUE(P_CPOS) TYPE I.
* Assigning fieldname,column text,column position to field catalog
  FS_CAT-FIELDNAME = P_FNAME.
  FS_CAT-COLTEXT = P_CTEXT.
  FS_CAT-COL_POS = P_CPOS.
  APPEND FS_CAT TO T_CAT.
  CLEAR FS_CAT.
ENDFORM. " POP_FCAT