Skip to Content
0
Former Member
Apr 25, 2007 at 02:47 PM

Need help with my Report Header

30 Views

Hi

I have this report that I had to add a column to. which i did. but the problem is I can't find where the report getting its header information from so that I can shift it so that it apears correct format.

Here is the code

*&---------------------------------------------------------------------*
*& Report  ZSALES                                                      *
*----------------------------------------------------------------------*
* Report runs by sales employee, by period (invoice month).  It        *
* displays the contract number, invoice number & amount for the period *
* and sold-to and ship-to partners of the contract.                    *
*----------------------------------------------------------------------*
*  MODIFICATION LOG                                                    *
*    DATE          AUTHOR          DESCRIPTION                         *
*   10/12/98       gubbi           Original Version                    *
*   01/14/99       gubbi           added selection criteria - material *
*                                  sold-to and bill-to parties         *
*   05/23/99       bchakraborty    added the contract type select      *
*                                  criteria                            *
*  04/25/07        akabir          adding Emp#                         *
*----------------------------------------------------------------------*

REPORT  ZSALES
                 LINE-SIZE 260 LINE-COUNT 65(3).

TABLES: S006,
        TVAKT,
        VBRP,     "Billing: Item Data
        VBRK,     "Billing: Header Data
        VEDA,
        VBAP,
        ENT6030,
        ENT6418,  "Partner sales activity-employee-assignment
        STXL,     "STXD SAPscript text file lines
        VBPA.

DATA: BEGIN OF REC OCCURS 0,
      VRTNR LIKE S006-VRTNR,           " sales employee
      SPBUP LIKE S006-SPBUP,           " period of analysis
      VBELN LIKE ENT6418-VBELN,        " contract number
      POSNR LIKE ENT6418-POSNR,        " contract line item number
      MATNR LIKE VBAP-MATNR,           " material number
      VBEGDAT LIKE VEDA-VBEGDAT,       " contract begin date
      VENDDAT LIKE VEDA-VENDDAT,       " contract end date
      PSTYV LIKE VBAP-PSTYV,           " item category
      INVOICE LIKE VBRP-VBELN,         " invoice number(billing doc.)
      ITEM LIKE VBRP-POSNR,            " invoice line item number
      SOLD_TO LIKE ENT6030-KUNNR,      " sold-to party
      SHIP_TO LIKE ENT6030-KUNNR,      " ship-to party
      BILL_TO LIKE ENT6030-KUNNR,      " bill-to party
      FKDAT LIKE VBRK-FKDAT,           " invoice date
      FKART LIKE VBRK-FKART,           " billing type
      NETWR LIKE VBRK-NETWR.           " invoice amount
DATA: END OF REC.

DATA: T_PERNR LIKE PERNR-PERNR,
      TEMP(6),
      PRINT_OUT, GET_MATRL.
* MES Moved to Global
DATA: BEGIN OF ADDR,
      NAME1 LIKE KNA1-NAME1,
      NAME2 LIKE KNA1-NAME2,
      END OF ADDR.



SELECTION-SCREEN BEGIN OF BLOCK ELMO WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: D_VKORG FOR S006-VKORG,       " sales organization
                DST_CHAN FOR S006-VTWEG,      " distribution channel
                DIV FOR S006-SPART,           " division
                EMPL_NO FOR S006-VRTNR,       " sales employee number
                SOLD_TO FOR ENT6030-KUNNR,    " sold to party
                BILL_TO FOR ENT6030-KUNNR,    " bill to party
                SHIP_TO FOR ENT6030-KUNNR,    " ship to party
                MATERIAL FOR S006-MATNR,      " material number
                PERIOD FOR S006-SPBUP,        " analysis period
                D_AUART FOR TVAKT-AUART.      "Contract type
SELECTION-SCREEN END OF BLOCK ELMO.

SELECTION-SCREEN BEGIN OF BLOCK CHARLY WITH FRAME TITLE TEXT-002.
PARAMETERS: INVOICE RADIOBUTTON GROUP Z1,
            COMISION RADIOBUTTON GROUP Z1.
SELECTION-SCREEN END OF BLOCK CHARLY.


"==================== Start Program ====================================
   TOP-OF-PAGE.
*   perform print_page_headings.

   END-OF-PAGE.
   SKIP 1.
   FORMAT INTENSIFIED OFF.
*   write: / 'Note:  INVOICE TEXT IS BASED ON CURRENT INFORMATION',
*          / '       AND MAY NOT MATCH THE ORIGINAL INVOICE'.
   FORMAT RESET.

   START-OF-SELECTION.
* commission report
   IF COMISION EQ 'X'.
   SELECT DISTINCT VRTNR  FROM S006  INTO T_PERNR
                      WHERE VKORG IN D_VKORG AND
                            SPART IN DIV AND
                            VRTNR IN EMPL_NO AND
                            VTWEG IN DST_CHAN AND
                            SPBUP IN PERIOD.
        AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
                 ID 'VKORG' FIELD S006-VKORG
                 ID 'VTWEG' FIELD S006-VTWEG
                 ID 'SPART' FIELD S006-SPART
                 ID 'ACTVT' FIELD '03'.
       IF SY-SUBRC EQ 0.
       SELECT * FROM ENT6418 WHERE PERNR = T_PERNR AND
                                     PARVW = 'VE' AND  "sales employee
                                     VBELN >= '0090000000'.
             MOVE: ENT6418-PERNR TO REC-VRTNR.
             PERFORM GET_INVOICE_NUMBER.
             CLEAR: REC, TEMP.
       ENDSELECT.
       ENDIF.
   ENDSELECT.
* invoice registry report
   ELSEIF INVOICE EQ 'X'.
      SELECT * FROM VBRK
                      WHERE VKORG IN D_VKORG AND
                            SPART IN DIV AND
                            VTWEG IN DST_CHAN.
        AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
                 ID 'VKORG' FIELD VBRK-VKORG
                 ID 'VTWEG' FIELD VBRK-VTWEG
                 ID 'SPART' FIELD VBRK-SPART
                 ID 'ACTVT' FIELD '03'.
       IF SY-SUBRC EQ 0.
           PERFORM GET_SALES_EMPLOYEE.
           PERFORM GET_INFORMATION.
           CLEAR: REC, TEMP.
       ENDIF.
      ENDSELECT.
   ENDIF.
   END-OF-SELECTION.

   PERFORM PRINT_DATA.



*&---------------------------------------------------------------------*
*&      Form  GET_CONTRACT_NUMBER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_CONTRACT_NUMBER.
   SELECT SINGLE * FROM VBRP WHERE VBELN = ENT6418-VBELN AND
                                   POSNR = ENT6418-POSNR.
   IF SY-SUBRC EQ 0.
       MOVE: VBRP-AUBEL TO REC-VBELN,       " contract number
             VBRP-POSNR TO REC-POSNR.       " contract item number
       SELECT SINGLE * FROM VBAP WHERE VBELN = REC-VBELN AND
                                       POSNR = REC-POSNR.
       IF SY-SUBRC EQ 0.
          MOVE: VBAP-MATNR TO REC-MATNR,
                VBAP-PSTYV TO REC-PSTYV.
       ENDIF.
       SELECT SINGLE * FROM VEDA WHERE VBELN = REC-VBELN.
       IF SY-SUBRC EQ 0.
          MOVE: VEDA-VBEGDAT TO REC-VBEGDAT,
                VEDA-VENDDAT TO REC-VENDDAT.
       ENDIF.
   ENDIF.
   MOVE: ENT6418-VBELN TO REC-INVOICE,     " invoice number
         ENT6418-POSNR TO REC-ITEM.        " invoice item number
ENDFORM.                    " GET_CONTRACT_NUMBER



*&---------------------------------------------------------------------*
*&      Form  GET_INVOICE_NUMBER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_INVOICE_NUMBER.

       SELECT SINGLE * FROM VBRK WHERE VBELN = ENT6418-VBELN.
       IF SY-SUBRC EQ 0.
           PERFORM GET_INFORMATION.
       ENDIF.
       CLEAR: TEMP, REC.
ENDFORM.                    " GET_INVOICE_NUMBER



*&---------------------------------------------------------------------*
*&      Form  GET_SOLD_TO_SHIP_TO_PARTY
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_SOLD_TO_SHIP_TO_PARTY.

   SELECT * FROM VBPA WHERE VBELN = REC-VBELN.
*                 ( PARVW = 'AG' OR PARVW = 'WE' OR PARVW = 'RE' ).
      IF VBPA-PARVW EQ 'AG'.
         MOVE: VBPA-KUNNR TO REC-SOLD_TO.
      ELSEIF VBPA-PARVW EQ 'WE'.
         MOVE: VBPA-KUNNR TO REC-SHIP_TO.
      ELSEIF VBPA-PARVW EQ 'RE'.
         MOVE: VBPA-KUNNR TO REC-BILL_TO.
      ENDIF.
   ENDSELECT.
ENDFORM.                    " GET_SOLD_TO_SHIP_TO_PARTY



*&---------------------------------------------------------------------*
*&      Form  PRINT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM PRINT_DATA.

       DATA: NAME(25),
             TEXT LIKE TVFKT-VTEXT.


       SORT REC BY SPBUP
                   VRTNR
                   INVOICE ITEM.
       FORMAT RESET.

       LOOP AT REC.
          AT NEW SPBUP.
*             new-page.
          ENDAT.
* Get contract type first for selection criteria
          PERFORM GET_CONTRACT_TYPE.
* only continue if contract type is in selection
       IF PRINT_OUT = 'Y'.


* Employee name note required

          PERFORM GET_EMPLOYEE_NAME USING NAME.
          perform get_billing_type_text using text.
*          write: / 'Sales Employee: ', rec-vrtnr, name.
          write: 1 rec-vrtnr.
          clear: name.
          IF REC-FKART EQ 'S1'.
             FORMAT COLOR COL_NEGATIVE.
          ENDIF.

          WRITE: 170 REC-INVOICE, REC-ITEM. " Invoice #
*          write: /10 'Billing Type: ', 30 rec-fkart, text.
          FORMAT RESET.
          CLEAR: TEXT.
*          write: /10 'Invoice Date: ',
           WRITE:  185 REC-FKDAT MM/DD/YY,
                   (10) REC-NETWR, 'USD'.

*          write: /10 'Sold-to Party: ', 30 rec-sold_to.
          WRITE: 11 REC-SOLD_TO. " 10 addr.
          PERFORM GET_CUSTOMER_NAME USING REC-SOLD_TO.


*          write: /10 'Ship-to Party: ', 30 rec-ship_to.
          WRITE: 60 REC-SHIP_TO. " 60 addr.
          PERFORM GET_CUSTOMER_NAME USING REC-SHIP_TO.

*          write: /10 'Bill-to Party: ', 30 rec-bill_to.
*          perform get_customer_name using rec-bill_to.
*          write: 0 rec-bill_to, 10 addr.

          WRITE: 155 REC-VBELN. " , rec-posnr. "Contract
          WRITE: 220 REC-VBEGDAT, REC-VENDDAT.

*          perform get_contract_type.
*          perform get_item_category_text.
*          perform get_long_text.
        IF GET_MATRL NE 'N'.
           PERFORM GET_MATERIAL_TEXT.
        ENDIF.

*         write: 105 rec-invoice, rec-item. " Invoice #
WRITE:/.
*         uline.
ENDIF.   " if contract selection
          AT LAST.
          SUM.
          WRITE: /55 'Totals:        ', (10) REC-NETWR.
          ULINE.
          ENDAT.
       ENDLOOP.

ENDFORM.                    " PRINT_DATA



*&---------------------------------------------------------------------*
*&      Form  GET_EMPLOYEE_NAME
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_EMPLOYEE_NAME USING    P_NAME.

CALL FUNCTION 'Z_GET_EMPLOYEE_NAME'
     EXPORTING
          EMPL_NO = REC-VRTNR
    IMPORTING
         NAME    = P_NAME
     EXCEPTIONS
          OTHERS  = 1.

ENDFORM.                    " GET_EMPLOYEE_NAME



*&---------------------------------------------------------------------*
*&      Form  GET_LONG_TEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_LONG_TEXT.
       DATA: DUMMY LIKE THEAD-TDNAME,
             LINES TYPE I.

       DATA: BEGIN OF TABLE_LINES OCCURS 0.
             INCLUDE STRUCTURE TLINE.
       DATA: END OF TABLE_LINES.

       DATA: BEGIN OF IN_LINES OCCURS 0.
             INCLUDE STRUCTURE TLINE.
       DATA: END OF IN_LINES.

       CONCATENATE REC-VBELN REC-POSNR INTO DUMMY.
       SELECT * FROM STXL WHERE TDOBJECT = 'VBBP' AND
                            TDNAME = DUMMY.

       CALL FUNCTION 'READ_TEXT_INLINE'
            EXPORTING
                 ID              = STXL-TDID
                 INLINE_COUNT    = 1
                 LANGUAGE        = 'E'
                 NAME            = DUMMY
                 OBJECT          = 'VBBP'
*           IMPORTING
*                HEADER          =
            TABLES
                 INLINES         = IN_LINES
                 LINES           = TABLE_LINES
            EXCEPTIONS
                 ID              = 1
                 LANGUAGE        = 2
                 NAME            = 3
                 NOT_FOUND       = 4
                 OBJECT          = 5
                 REFERENCE_CHECK = 6
                 OTHERS          = 7.
      DESCRIBE TABLE TABLE_LINES LINES LINES.
      IF SY-SUBRC EQ 0.
         SKIP 1.
         WRITE: / 'Item Text: '.
      ENDIF.
      CLEAR LINES.
      LOOP AT TABLE_LINES.
         WRITE: / TABLE_LINES-TDLINE.
      ENDLOOP.

      REFRESH TABLE_LINES.
      CLEAR: TABLE_LINES.
      ENDSELECT.
ENDFORM.                    " GET_LONG_TEXT



*&---------------------------------------------------------------------*
*&      Form  GET_CUSTOMER_NAME
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_CUSTOMER_NAME USING    P_CUST_NO.

*data: begin of addr,
*      name1 like kna1-name1,
*      name2 like kna1-name2,
*      end of addr.

DATA: STREET LIKE KNA1-STRAS,
      CITY LIKE KNA1-ORT01,
      STATE LIKE KNA1-REGIO,
      ZIP LIKE KNA1-PSTLZ.

CALL FUNCTION 'Z_GET_CUSTOMER_NAME_ADDRESS'
     EXPORTING
          CUST_NO = P_CUST_NO
    IMPORTING
         NAME1   = ADDR-NAME1
         NAME2   = ADDR-NAME2
         STREET  = STREET
         CITY    = CITY
         STATE   = STATE
         ZIP     = ZIP
     EXCEPTIONS
          OTHERS  = 1.

   CONDENSE ADDR.
* MES Don't need to print in this report
  WRITE: ADDR(20).
*         /30 street,
*         /30 city, state, zip.
   CLEAR: ADDR, STREET, CITY, STATE, ZIP.
ENDFORM.                    " GET_CUSTOMER_NAME



*&---------------------------------------------------------------------*
*&      Form  PRINT_PAGE_HEADINGS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM PRINT_PAGE_HEADINGS.
   DATA: MO(2), YR(4),
         TEMP_NAME(80) VALUE SPACE.
   WRITE: / SY-REPID.
   IF COMISION EQ 'X'.
       CALL FUNCTION 'Z_PRINT_PAGE_HEADINGS'
            EXPORTING
                   STRING  = 'COMMISSION REPORT'
            EXCEPTIONS
                   OTHERS  = 1.
   ELSE.
       CALL FUNCTION 'Z_PRINT_PAGE_HEADINGS'
            EXPORTING
                   STRING  = 'INVOICE REPORT'
            EXCEPTIONS
                   OTHERS  = 1.
   ENDIF.

   TEMP_NAME = 'PERIOD: '.
   MO = REC-SPBUP+4(2).
   YR = REC-SPBUP(4).
   FORMAT INTENSIFIED ON.
   CONCATENATE TEMP_NAME MO '/' YR INTO TEMP_NAME.
   WRITE: / TEMP_NAME CENTERED.
   CLEAR: MO, YR, TEMP_NAME.

   IF D_VKORG <> SPACE.
      TEMP_NAME = 'SALES ORGANIZATION:'.
      IF D_VKORG-HIGH <> SPACE.
          CONCATENATE TEMP_NAME D_VKORG-LOW ' TO:' D_VKORG-HIGH INTO
                            TEMP_NAME.
      ELSE.
          CONCATENATE TEMP_NAME D_VKORG-LOW INTO TEMP_NAME.
      ENDIF.
   ENDIF.
   IF TEMP_NAME <> SPACE.
          WRITE: / TEMP_NAME CENTERED.
          CLEAR TEMP_NAME.
   ENDIF.
   IF DST_CHAN <> SPACE.
      TEMP_NAME = 'DISTRIBUTION CHANNEL:'.
      IF DST_CHAN-HIGH <> SPACE.
          CONCATENATE TEMP_NAME DST_CHAN-LOW ' TO:' DST_CHAN-HIGH INTO
                            TEMP_NAME.
      ELSE.
          CONCATENATE TEMP_NAME DST_CHAN-LOW INTO TEMP_NAME.
      ENDIF.
   ENDIF.
   IF TEMP_NAME <> SPACE.
          WRITE: / TEMP_NAME CENTERED.
          CLEAR TEMP_NAME.
   ENDIF.
   IF DIV <> SPACE.
      TEMP_NAME = 'DIVISION:'.
      IF DIV-HIGH <> SPACE.
          CONCATENATE TEMP_NAME DIV-LOW ' TO:' DIV-HIGH INTO
                            TEMP_NAME.
      ELSE.
          CONCATENATE TEMP_NAME DIV-LOW INTO TEMP_NAME.
      ENDIF.
   ENDIF.
   IF TEMP_NAME <> SPACE.
          WRITE: / TEMP_NAME CENTERED.
          CLEAR TEMP_NAME.
   ENDIF.
* uline.
   FORMAT RESET.

ENDFORM.                    " PRINT_PAGE_HEADINGS



*&---------------------------------------------------------------------*
*&      Form  GET_SALES_EMPLOYEE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_SALES_EMPLOYEE.

   SELECT SINGLE * FROM ENT6418 WHERE VBELN = VBRK-VBELN AND
                                      PARVW = 'RE'.
   IF SY-SUBRC EQ 0.
      MOVE: ENT6418-PERNR TO REC-VRTNR.
   ENDIF.
   SELECT SINGLE * FROM ENT6418 WHERE VBELN = VBRK-VBELN AND
                                      PARVW = 'WE'.
ENDFORM.                    " GET_SALES_EMPLOYEE



*&---------------------------------------------------------------------*
*&      Form  GET_INFORMATION
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_INFORMATION.
           TEMP = VBRK-FKDAT(6).
           CHECK TEMP IN PERIOD.
           MOVE: VBRK-FKDAT TO REC-FKDAT,  " invoice date
                 VBRK-FKART TO REC-FKART,  " billing type
                 TEMP TO REC-SPBUP.
* subtract the amount if the invoice is cancelled.
* chakraborty. added the G2 and RE criteria to billing type
           IF REC-FKART EQ 'S1'.         " cancellation of inventory
                 REC-NETWR = -1 * VBRK-NETWR.  " invoice amount
           ELSEIF REC-FKART EQ 'G2'.     "  credit memo
                 REC-NETWR = -1 * VBRK-NETWR.
           ELSEIF REC-FKART EQ 'RE'.     " credit for returns
                 REC-NETWR = -1 * VBRK-NETWR.
           ELSE.
                 REC-NETWR = VBRK-NETWR.
           ENDIF.
           PERFORM GET_CONTRACT_NUMBER.
           PERFORM GET_SOLD_TO_SHIP_TO_PARTY.

           IF REC-SOLD_TO IN SOLD_TO AND REC-BILL_TO IN BILL_TO AND
                          REC-MATNR IN MATERIAL AND
                          REC-SHIP_TO IN SHIP_TO.
               APPEND REC.
           ENDIF.
           CLEAR REC.

ENDFORM.                    " GET_INFORMATION



*&---------------------------------------------------------------------*
*&      Form  GET_BILLING_TYPE_TEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_BILLING_TYPE_TEXT USING    P_TEXT.
   TABLES: TVFKT.

   SELECT SINGLE * FROM TVFKT WHERE SPRAS = 'E' AND
                                    FKART = REC-FKART.
   IF SY-SUBRC EQ 0.
      MOVE: TVFKT-VTEXT TO P_TEXT.
   ENDIF.
ENDFORM.                    " GET_BILLING_TYPE_TEXT



*&---------------------------------------------------------------------*
*&      Form  GET_CONTRACT_TYPE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM GET_CONTRACT_TYPE.
    TABLES: VIVEDA.
*            TVAKT.
    DATA: P_T_BEZEI LIKE TVAKT-BEZEI,
          P_T_AUART LIKE TVAKT-AUART.
    SKIP 1.
    SELECT SINGLE AUART FROM VIVEDA INTO P_T_AUART
                           WHERE VBELN = REC-VBELN AND
                                 POSNR = REC-POSNR.
   IF P_T_AUART = 'ZWV'.
      SELECT SINGLE BEZEI FROM TVAKT INTO P_T_BEZEI
                          WHERE AUART = P_T_AUART AND SPRAS = 'E'
                          AND AUART IN D_AUART.

    WRITE: /110 P_T_AUART, 117 P_T_AUART , P_T_BEZEI.
   ENDIF.

   IF P_T_AUART IN D_AUART.
      PRINT_OUT = 'Y'.
     WRITE: /210 P_T_AUART.
   ELSE.
      PRINT_OUT = 'N'.
   ENDIF.
    CLEAR: P_T_AUART, P_T_BEZEI.

ENDFORM.                    " GET_CONTRACT_TYPE



*&---------------------------------------------------------------------*
*&      Form  GET_ITEM_CATEGORY_TEXT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_TEXT  text                                               *
*----------------------------------------------------------------------*
FORM GET_ITEM_CATEGORY_TEXT.

   TABLES: TVAPT.
   SELECT SINGLE * FROM TVAPT WHERE SPRAS = 'E' AND
                                    PSTYV = REC-PSTYV.
   IF SY-SUBRC EQ 0.
      WRITE: /20 'Item Category: ', REC-PSTYV, TVAPT-VTEXT.
   ENDIF.
ENDFORM.                    " GET_ITEM_CATEGORY_TEXT



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

   TABLES: MAKT.

   SELECT SINGLE * FROM MAKT WHERE MATNR = REC-MATNR AND
                                   SPRAS = 'E'.
   IF SY-SUBRC EQ 0.
      WRITE: 110 REC-MATNR, 117 MAKT-MAKTX(35).
   ENDIF.
ENDFORM.                    " GET_MATERIAL_TEXT

I was wondering if one of the experts can tell me how to get to the header.

There r previously wrtten code for header in there which is * marked. so its not using it. but may be I am missing some thing here