This website is not affiliated with, sponsored by, or approved by SAP AG.

Writing select-option values on top-of-page

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Writing select-option values on top-of-page

Postby YSP1 » Tue Jan 21, 2003 10:48 am

I am running a report for select options for purchasing group 0010 to 0080. There is any easy way I want to write all purchasing group description from 0010 to 0080 on top of page event.
Juat I want to write all selection on top of page with description any easy way to do this

Thanks in advance
ysp1
YSP1
 

Postby Julie McAfee » Tue Jan 21, 2003 11:08 am

Function Module RS_COVERPAGE_SELECTIONS will print the selection criteria.

Julie
Julie McAfee
 

Postby Rich » Tue Jan 21, 2003 11:34 am

Or conversely, download docs.zip frpom the repositary. This contains amongst other things a macro to do the same thing which makes life a little easier.

Note that this is an old version. For a more uptodate, cleaner version of the same e-mail me at hotmail.

Docs.zip contains many routines useful in reporting environments and Call Transaction programs.

Rich
Rich
 
Posts: 7112
Joined: Thu Oct 31, 2002 4:47 pm
Location: Liverpool

Writing select-option values on top-of-page

Postby ysp1 » Tue Jan 21, 2003 12:07 pm

Thanks for the reply
I am using ALV
So RS_COVERPAGE_SELECTIONS' and also PRINT_SELECTIONS is not giving correct output. Anybody know how to write selection screen in ALV

Thanks
ysp1
ysp1
 

Postby Tim van Steenbergen » Tue Jan 21, 2003 12:41 pm

Take a look at this alv-sample-code. It defines the event TOP-OF-PAGE in which you can print anything you want, including SO_...-low to SO_...-high, which you can insert at *()*
Code: Select all
REPORT ZALV_SAMPLE.
*                 NO STANDARD PAGE HEADING
*                 LINE-COUNT 58
*                 LINE-SIZE  220.

TYPE-POOLS: SLIS.                     "for 'REUSE_ALV...list&grids'
*----------------------------------------------------------------------*
* TABLES                                                               *
*----------------------------------------------------------------------*
TABLES: KNA1.      "General Data in Customer Master
                                                                       .
*----------------------------------------------------------------------*
* Internal data                                                        *
*----------------------------------------------------------------------*
DATA: BEGIN OF LT_ALVTABLE OCCURS 0,
        KUNNR LIKE KNA1-KUNNR,
        NAME1 LIKE KNA1-NAME1,
        NAME2 LIKE KNA1-NAME2,
        STRAS LIKE KNA1-STRAS,
        PSTLZ LIKE KNA1-PSTLZ,
        ORT01 LIKE KNA1-ORT01,
        UMSA1 LIKE KNA1-UMSA1,
        KTOKD LIKE KNA1-KTOKD,
      END OF LT_ALVTABLE.

* data-statements that are necessary for the use of the ALV-grid
DATA:  GT_XEVENTS     TYPE SLIS_T_EVENT.
DATA:  XS_EVENT       TYPE SLIS_ALV_EVENT.
DATA:  REPID          TYPE SY-REPID.
DATA:  ZTA_PRINT      TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
DATA:  LO_LAYOUT      TYPE SLIS_LAYOUT_ALV.
DATA:  LO_ITABNAME    TYPE SLIS_TABNAME.
DATA:  LS_VARIANT     TYPE DISVARIANT.

*----------------------------------------------------------------------*
* Initialization                                                       *
*----------------------------------------------------------------------*
INITIALIZATION.
*----------------------------------------------------------------------*
* Parameters and select-options                                        *
*----------------------------------------------------------------------*
   SELECT-OPTIONS SO_KUNNR FOR KNA1-KUNNR DEFAULT '2000' TO '2300'.
   SELECT-OPTIONS SO_NAME  FOR KNA1-NAME1.
   PARAMETERS: PA_PSTCD AS CHECKBOX       DEFAULT 'X'.
   PARAMETERS: PA_VAR   AS CHECKBOX       DEFAULT 'X'.
*----------------------------------------------------------------------*
* Start of main program                                                *
*----------------------------------------------------------------------*
START-OF-SELECTION.
   PERFORM SELECT_RECORDS.
   PERFORM PRINT_ALVLIST.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  select_records
*&---------------------------------------------------------------------*
FORM SELECT_RECORDS.

   SELECT * FROM KNA1 INTO CORRESPONDING FIELDS OF LT_ALVTABLE
     WHERE KUNNR IN SO_KUNNR
       AND NAME1 IN SO_NAME.
     APPEND LT_ALVTABLE.
   ENDSELECT.

ENDFORM.                              " select_records
*&--------------------------------------------------------------------*
*&      Form  print_alvlist
*&--------------------------------------------------------------------*
FORM PRINT_ALVLIST.

   REPID = SY-REPID.
   LO_ITABNAME = 'LT_ALVTABLE'.        "NB: ONLY USE CAPITALS HERE!

* Fill the variables of the ALV-grid.
   PERFORM SET_LAYOUT USING LO_LAYOUT. "Change layout-settings
   PERFORM SET_EVENTS USING GT_XEVENTS."Set the events (top-page etc)
   PERFORM FILL_STRUCTURE.             "Read the structure of the itab
   PERFORM MODIFY_STRUCTURE.           "Modify itab's field-properties

* Sort the table
   SORT LT_ALVTABLE BY KUNNR.

* Present the table using the ALV-grid.
   CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
             I_CALLBACK_PROGRAM = REPID
             IT_FIELDCAT        = ZTA_PRINT[]
             IS_LAYOUT          = LO_LAYOUT
             IT_EVENTS          = GT_XEVENTS
             I_SAVE             = 'A'
             IS_VARIANT         = LS_VARIANT
        TABLES
             T_OUTTAB           = LT_ALVTABLE.

ENDFORM.                              " print_alvlist
*&---------------------------------------------------------------------*
*&      Form  SET_LAYOUT
*&---------------------------------------------------------------------*
FORM SET_LAYOUT USING PA_LAYOUT TYPE SLIS_LAYOUT_ALV.

* Minimize the columnwidth
  PA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
* Give the table a striped pattern
  PA_LAYOUT-ZEBRA             = 'X'.
* Set the text of the line with totals
  PA_LAYOUT-TOTALS_TEXT       = 'Total:'.
* Set the text of the line with subtotals
  PA_LAYOUT-SUBTOTALS_TEXT    = 'Subtotal:'.

* Set the variant, as requested via the checkbox
  IF PA_VAR = 'X'.
    LS_VARIANT-VARIANT = '/ZLAYOUT'.
  ELSE.
    CLEAR LS_VARIANT-VARIANT.
  ENDIF.

ENDFORM.                              " SET_LAYOUT
*&--------------------------------------------------------------------
*&     Form Set_events
*&--------------------------------------------------------------------
*      Appends the values of the events to the events-variable that is
*      used by REUSE_ALV_LIST_DISPLAY
*&--------------------------------------------------------------------
FORM SET_EVENTS USING PA_EVENTS TYPE SLIS_T_EVENT.

   XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.
   XS_EVENT-FORM = 'XTOP_OF_LIST'.
   APPEND XS_EVENT TO PA_EVENTS.

   XS_EVENT-NAME = SLIS_EV_END_OF_LIST.
   XS_EVENT-FORM = 'XEND_OF_LIST'.
   APPEND XS_EVENT TO PA_EVENTS.

   XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
   XS_EVENT-FORM = 'XTOP_OF_PAGE'.
   APPEND XS_EVENT TO PA_EVENTS.

   XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.
   XS_EVENT-FORM = 'XEND_OF_PAGE'.
   APPEND XS_EVENT TO PA_EVENTS.

ENDFORM.

*&--------------------------------------------------------------------*
*&      Form  XTOP_OF_LIST
*&--------------------------------------------------------------------*
FORM XTOP_OF_LIST.
   DATA LO_DATE(8).
   CONCATENATE SY-DATUM+6(2) '.'
               SY-DATUM+4(2) '.'
               SY-DATUM+2(2)
          INTO LO_DATE.

   WRITE: AT  1 'Report:'(T01), 20 'Reportname'(T02).
   WRITE: AT 50 'Date:'(T03), LO_DATE.
   NEW-LINE.
   WRITE: AT  1 'Abap-name report: '(T04), SY-REPID.
   WRITE: AT 50 'Page:'(T05), SY-CPAGE.
ENDFORM.                              "xtop_of_list
*&--------------------------------------------------------------------*
*&      Form  XEND_OF_LIST
*&--------------------------------------------------------------------*
FORM XEND_OF_LIST.
   WRITE: 'Footer of the list'(002).
ENDFORM.                              "xend_of_list
*&---------------------------------------------------------------------*
*&      Form  XTOP_OF_PAGE
*&---------------------------------------------------------------------*
FORM XTOP_OF_PAGE.
   WRITE:/ 'Top of the page.'(003).
*()*Here your selection-criteria can be printed
ENDFORM.                              "xtop-of-page
*&---------------------------------------------------------------------*
*&      Form  XEND_OF_PAGE
*&---------------------------------------------------------------------*
FORM XEND_OF_PAGE.
    WRITE:/ 'End of the page.'(004).
ENDFORM.                              "xtop-of-page
*&---------------------------------------------------------------------*
*&      Form  FILL_STRUCTURE
*&---------------------------------------------------------------------*
FORM FILL_STRUCTURE.

   CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
             I_PROGRAM_NAME     = REPID
             I_INTERNAL_TABNAME = LO_ITABNAME
             I_INCLNAME         = 'ZALV_SAMPLE'
        CHANGING
             CT_FIELDCAT        = ZTA_PRINT[].

ENDFORM.                              " FILL_STRUCTURE
*&--------------------------------------------------------------------*
*&      Form  MODIFY_STRUCTURE
*&--------------------------------------------------------------------*
*       Set the fieldproperties to your wishes
*&--------------------------------------------------------------------*
FORM MODIFY_STRUCTURE.
   LOOP AT ZTA_PRINT.
     CLEAR ZTA_PRINT-KEY.
     CASE ZTA_PRINT-FIELDNAME.
       WHEN 'KUNNR'.                  "Klantnummer
         ZTA_PRINT-COL_POS = 0.
         ZTA_PRINT-SELTEXT_S = 'Cstm'(H01).
         ZTA_PRINT-SELTEXT_M = 'Customer'(H01).
         ZTA_PRINT-SELTEXT_L = 'Customer is king'(H01).
       WHEN 'NAME1'.                   "Name1
         ZTA_PRINT-COL_POS = 1.
       WHEN 'NAME2'.                   "Name 2 (now set to invisible)
         ZTA_PRINT-COL_POS = 2.
         ZTA_PRINT-NO_OUT = 'X'.
       WHEN 'STRAS'.                   "Month
         ZTA_PRINT-COL_POS = 3.
       WHEN 'PSTLZ'.                   "Postcode
         ZTA_PRINT-COL_POS = 4.
         IF PA_PSTCD = ''.
           ZTA_PRINT-NO_OUT = 'X'.
         ELSE.
           CLEAR ZTA_PRINT-NO_OUT.
         ENDIF.
       WHEN 'ORT01'.                   "Stad
         ZTA_PRINT-COL_POS = 5.
       WHEN 'UMSA1'.                   "Annual sales
         ZTA_PRINT-COL_POS = 6.
       WHEN 'KTOKD'.                   "
         ZTA_PRINT-COL_POS = 7.
*      when others.                   "set all other fields to invisible
*        zta_print-no_out = 'X'.
     ENDCASE.
     MODIFY ZTA_PRINT.
   ENDLOOP.
ENDFORM.                              " modify_structure
Best regards, Tim van Steenbergen
Tim van Steenbergen
 
Posts: 346
Joined: Tue Dec 17, 2002 7:52 am
Location: Amsterdam, The Netherlands


Return to ABAP

Who is online

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 14 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.