Friday, 1 July 2016

Classical Basic report

Events in Classical Basic report

  • Initialization.
  • At-selection-screen.
  1. At-selection-screen output .
  2. At-selection-screen on <field> 
  3. At-selection-screen on value-request.
  4. At-selection-screen on help-request.
  • Start-of-selection.
  • End-of-selection.
  • Top-of-page.
  • End-of-page.


Explanation 

  • Initialization.
  1. To initialize the value to variables.
  2. To assign the values to parameter as well as select-option.
  • At-selection-screen.
  1. Used to validate  selection screen input.
  • At-selection-screen output .
  1. Used to modify the screen layout.
  • At-selection-screen on <field> 
  1. To validate the particular filed.
  • At-selection-screen on value-request.
  1. Used to provide search help for a particular field. 
  •  At-selection-screen on help-request.
  1. Used to provide documentation help for particular field.
  • Start-of-selection.
  1. Actual program execution starts from here.
  • End-of-selection.
  1. Usually output related  codes are written here.
  • Top-of-page.
  1. If you want put headings for report, then write code here.
  • End-of-page.
  1. Used to put footer .
Ex :



  • Go to Transaction code SE38.
  • Enter the program name start's with Y or Z<program name > and click on create button.
  • Enter the Title.
  • Select Attribute Type as Executable Program.
  • Click on save button.


  • Save it in either package or local package.





Source Code

REPORT  ZCLASSICAL_BASIC_SALES NO STANDARD PAGE HEADING LINE-SIZE 200
LINE-COUNT 30(3.

TABLES VBAK VBAP.

TYPES BEGIN OF TY_SA,
        VBELN TYPE VBAK-VBELN,
        POSNR TYPE VBAP-POSNR,
        ERDAT TYPE VBAK-ERDAT,
        ERNAM TYPE VBAK-ERNAM,
        VKORG TYPE VBAK-VKORG,
        KUNNR TYPE VBAK-KUNNR,
        MATNR TYPE VBAP-MATNR,
        ARKTX TYPE VBAP-ARKTX,
        ZMENG TYPE VBAP-ZMENG,
        NETWR TYPE VBAP-NETWR,
       END OF TY_SA.

DATA WA_SA TYPE TY_SA,
       IT_SA TYPE TABLE OF TY_SA.

DATA V_SKIP TYPE I.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
 PARAMETERS R1 RADIOBUTTON GROUP G1 USER-COMMAND U1.
  SELECT-OPTIONS S_VBELN FOR WA_SA-VBELN MODIF ID ABC.

  PARAMETERS R2 RADIOBUTTON GROUP G1.
  SELECT-OPTIONS S_ERDAT FOR WA_SA-ERDAT MODIF ID XYZ.
 PARAMETERS P_VKORG TYPE VBAK-VKORG OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.

INITIALIZATION.
S_VBELN-SIGN 'I'.
S_VBELN-OPTION 'BT'.
S_VBELN-LOW '5015'.
S_VBELN-HIGH '6015'.

APPEND S_VBELN .

P_VKORG '1000'.

AT SELECTION-SCREEN.

SELECT SINGLE VBELN FROM VBUK INTO VBAK-VBELN WHERE VBELN IN S_VBELN.
  IF SY-SUBRC NE 0.
  MESSAGE 'SALES ODER NUMBER  NOT FOUND ' TYPE 'E'.
  ENDIF.




 AT SELECTION-SCREEN OUTPUT.
 LOOP AT SCREEN.
   IF  SCREEN-GROUP1 'ABC'.
     IF R2 'X'.
        SCREEN-ACTIVE 0.

     ENDIF.
    IF R1 'X'.
     SCREEN-ACTIVE 1.
    ENDIF.
   ENDIF.


   IF  SCREEN-GROUP1 'XYZ'.
     IF R1 'X'.
        SCREEN-ACTIVE 0.

     ENDIF.
    IF R2 'X'.
     SCREEN-ACTIVE 1.
    ENDIF.
   ENDIF.
   MODIFY SCREEN.
 ENDLOOP.

 AT SELECTION-SCREEN ON P_VKORG.

 SELECT SINGLE VKORG FROM TVKO INTO VBAK-VKORG WHERE VKORG P_VKORG.

   IF SY-SUBRC NE 0.
  MESSAGE 'SALES ORG. NOT FOUND ' TYPE 'E'.
  ENDIF.

  AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_VBELN-LOW.

    TYPESBEGIN OF TY_F4,
           VBELN TYPE VBAK-VBELN,
           KUNNR TYPE VBAK-KUNNR,
          END OF TY_F4.
  DATA WA_F4 TYPE TY_F4,
         IT_F4 TYPE TABLE OF TY_F4.

  SELECT VBELN KUNNR FROM VBAK INTO TABLE IT_F4.

 call function 'F4IF_INT_TABLE_VALUE_REQUEST'
   exporting
*    DDIC_STRUCTURE         = ' '
     retfield               'VBELN'
*    PVALKEY                = ' '
    DYNPPROG               SY-REPID
    DYNPNR                 '1000'
    DYNPROFIELD            'S_VBELN'
*    STEPL                  = 0
    WINDOW_TITLE           'VALUE HELP FOR SALES DOC'
*    VALUE                  = ' '
    VALUE_ORG              'S'
*    MULTIPLE_CHOICE        = ' '
*    DISPLAY                = ' '
*    CALLBACK_PROGRAM       = ' '
*    CALLBACK_FORM          = ' '
*    CALLBACK_METHOD        =
*    MARK_TAB               =
*  IMPORTING
*    USER_RESET             =
   tables
     value_tab              =     IT_F4
*    FIELD_TAB              =
*    RETURN_TAB             =
*    DYNPFLD_MAPPING        =
  EXCEPTIONS
    PARAMETER_ERROR        1
    NO_VALUES_FOUND        2
    OTHERS                 3
           .
 if sy-subrc <> 0.
* Implement suitable error handling here
 endif.

 AT SELECTION-SCREEN ON HELP-REQUEST FOR P_VKORG.

   TYPES BEGIN OF TY_F1,
           TXT(80TYPE C,
           END OF TY_F1.

 DATA WA_F1 TYPE TY_F1,
        IT_F1 TYPE TABLE OF TY_F1.

 WA_F1-TXT 'THIS IS SALES ODER NUMBER'.
 APPEND WA_F1 TO IT_F1.

 CLEAR WA_F1.
   WA_F1-TXT 'PLAESE ENTER SALES ODER NUMBER'.
 APPEND WA_F1 TO IT_F1.
  CLEAR WA_F1.

  call function 'POPUP_WITH_TABLE_DISPLAY_OK'
    exporting
      endpos_col         60
      endpos_row         60
      startpos_col       3
      startpos_row       3
      titletext          'SALES HELP'
*   IMPORTING
*     CHOISE             =
    tables
      valuetab           IT_F1
   EXCEPTIONS
     BREAK_OFF          1
     OTHERS             2
            .
  if sy-subrc <> 0.
* Implement suitable error handling here
  endif.

  START-OF-SELECTION.

IF R1 'X'.

SELECT A~VBELN
       POSNR
       A~ERDAT
       A~ERNAM
       VKORG
       KUNNR
       MATNR
       ARKTX
       ZMENG
       B~NETWR INTO TABLE IT_SA FROM VBAK AS A INNER JOIN VBAP AS B
     ON B~VBELN A~VBELN WHERE A~VBELN IN S_VBELN AND VKORG P_VKORG.

ENDIF.

IF R2 'X'.

SELECT A~VBELN
       POSNR
       A~ERDAT
       A~ERNAM
       VKORG
       KUNNR
       MATNR
       ARKTX
       ZMENG
       B~NETWR INTO TABLE IT_SA FROM VBAK AS A INNER JOIN VBAP AS B
     ON B~VBELN A~VBELN WHERE A~ERDAT IN S_ERDAT AND VKORG P_VKORG.
ENDIF.




END-OF-SELECTION.

LOOP AT IT_SA INTO WA_SA.

  WRITE /3 WA_SA-VBELN ,
           15 WA_SA-POSNR ,
            25 WA_SA-ERDAT,
           50 WA_SA-ERNAM,
          76  WA_SA-VKORG,
          100  WA_SA-KUNNR,
          120 WA_SA-MATNR,
          145  WA_SA-ARKTX,
          175  WA_SA-ZMENG LEFT-JUSTIFIED,
          190  WA_SA-NETWR CENTERED.
V_SKIP SY-LINCT SY-LINNO 3.
ENDLOOP.
SKIP V_SKIP.
TOP-OF-PAGE.

WRITE / SY-ULINE,
        / SY-VLINE 50 'SALES ORDER REPORT ' 200 SY-VLINE,
        / SY-ULINE.
WRITE /2 'SAL NO' 15 'ITEM NO'25 'DATE'50 'NAME' ,
76 'SALES ORG' 100 'CUSTOMER' 120 'MAT NO' 145 ' DESCRIPTION',
175 'QUANTITY' 190 'PRICE'/ SY-ULINE.

END-OF-PAGE.

WRITE / SY-ULINE ,
        / SY-VLINE 30 ' PAGE NO ' SY-PAGNO 200 SY-VLINE,
        / SY-ULINE.

  • Save ->Check->Activate.

  • Execute (F8).



Input -1

  • Click on R2 radio button.
  • Click on Execute.

Output



Input-2

  • Click on R2 radio button.
  • Click on Execute.

Output

                                                 more information............



No comments:

Post a Comment