+ -

Pages

Saturday, July 26, 2014

Writing Select-Options in report

Sometimes you may want to write the selection criterieas from the report selection-screen  to the report. here are 2 examples of how this can be done.

Example 1 Using a Function module

This exampel uses a standard function module RS_COVERPAGE_SELECTIONS.

Code

REPORT  z_hfnk_slam1                            .

DATA: BEGIN OF info OCCURS 0,
      flag,
      olength TYPE x,
      line  LIKE rsvar-infoline,
      END OF info,
      delete_index LIKE sy-tabix.


PARAMETER:
   p_name(10) TYPE c,
   p_test(2) TYPE n.


START-OF-SELECTION.
  PERFORM front_page.

END-OF-SELECTION.



*&---------------------------------------------------------------------*
*&      Form  FRONT_PAGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM front_page.
  CALL FUNCTION 'RS_COVERPAGE_SELECTIONS'
    EXPORTING
      report            = sy-cprog
      variant           = ' '                    "sy-slset
      no_import         = ' '
    TABLES
      infotab           = info
    EXCEPTIONS
      error_message     = 1
      variant_not_found = 3
      OTHERS            = 2.
*         others            = 4.

  LOOP AT info.
*  Clean up blank lines and "No selections"
    IF info-line CS 'No selections'
    OR info-line+1(77) IS INITIAL.
      delete_index = sy-tabix - 1.
      DELETE info INDEX sy-tabix.
      READ TABLE info INDEX delete_index.
      IF NOT info-line+2(1) IS INITIAL.
        DELETE info INDEX delete_index.
      ENDIF.
      CONTINUE.

    ENDIF.
  ENDLOOP.
  PERFORM write_cover.
ENDFORM.                    "FRONT_PAGE

*&---------------------------------------------------------------------*
*&      Form  WRITE_COVER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM write_cover.
  LOOP AT info.
    IF info-line CS 'Invisible'.
      info-line = sy-uline.
      WRITE: / info-line.
      EXIT.
    ENDIF.
    WRITE: / info-line.
  ENDLOOP.
  NEW-PAGE.
ENDFORM.                    "WRITE_COVER

Selection screen

Example 2 Doing it yourself


Structure of select options:

  • LOW    Low value
  • HIGH   High value
  • SIGN   E = Excluding, I = Including
  • OPTION BT = Between EQ = Equal

Code:

ata:
     l_sign(2) type c,
     l_option(3) type c.

  WRITE AT 3 'Printdoc:' INTENSIFIED ON.
    loop at s_prtdoc.
       if s_prtdoc-sign = 'E'.
         l_sign = '<>'.
       else.
         l_sign = '='.
       endif.
       if s_prtdoc-option = 'EQ'.
         clear l_option.

       else.
         l_option = 'to'.
       endif.

       write at 35 l_sign.
       write at 39 s_prtdoc-low.
       write at 55 l_option.
       write at 59 s_prtdoc-high.
       new-line.
    endloop.

Result in the report:
                                                                       
  Printdoc:         =   800000000501    to 800000000501 
                         <>  800000000502                     
                         =   800000000503                     

                                                               

5 ABAP Tips: Writing Select-Options in report Sometimes you may want to write the selection criterieas from the report selection-screen  to the report. here are 2 examples of how this c...

No comments:

Post a Comment

< >