02/03/2013

SAP Sales Classical report

Summary 
This report for sales details various types sales 

------------------------------------------------------------------------------------------------------------
*********************************************************
*  REPORT :   ZCLASSICAL_REPORT
*  AUTHOR :  tech.sap29@gmail.com
*********************************************************
REPORT :   ZCLASSICAL_REPORT  
                   NO STANDARD PAGE HEADING
                   LINE-SIZE 120
                   LINE-COUNT 7(1).

TABLES: VBRK,
        TVKO.
DATA: ITAB LIKE VBRP OCCURS 0 WITH HEADER LINE,
      V_FLAG,
      V_NO TYPE I.

********************************************************************
*SELECTION-SCREEN
********************************************************************

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN MODIF ID XYZ,
                S_VKORG FOR TVKO-VKORG.
SELECTION-SCREEN: END OF BLOCK B1.

********************************************************************
*INITIALIZATION
********************************************************************

INITIALIZATION.
  V_FLAG = SPACE.


*AT SELECTION-SCREEN.
*  PERFORM VALIDATE_ALL.


AT SELECTION-SCREEN ON S_VBELN.
  IF NOT S_VBELN[] IS INITIAL.
    PERFORM VALIDATE_S_VBELN.
  ENDIF.

AT SELECTION-SCREEN ON S_VKORG.
  IF NOT S_VKORG[] IS INITIAL.
    PERFORM VALIDATE_S_VKORG.
  ENDIF.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    CHECK SCREEN-GROUP1 = 'XYZ'.
    SCREEN-INTENSIFIED = '1'.
    MODIFY SCREEN.
  ENDLOOP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_VBELN-LOW.
  MESSAGE I000(ZBDC) WITH 'ON VALUE REQUEST FOR S_VBELN'.

AT SELECTION-SCREEN ON HELP-REQUEST FOR S_VKORG-LOW.
  MESSAGE I000(ZBDC) WITH 'ON HELP REQUEST FOR S_VBELN'.


********************************************************************
*START-OF-SELECTION
********************************************************************
START-OF-SELECTION.
  PERFORM GET_DATA.

********************************************************************
*TOP-OF-PAGE
********************************************************************
TOP-OF-PAGE.
  PERFORM BUILD_HEADER.

********************************************************************
*END-OF-PAGE
********************************************************************
END-OF-PAGE.
  PERFORM BUILD_FOOTER.
*********************************************************************
* END-OF-SELECTION
*********************************************************************
END-OF-SELECTION.
  IF V_FLAG = 'X'.
    PERFORM DISP_DATA.
  ELSE.
    MESSAGE I004(ZBDC) WITH 'NO DATA FOUND TO DISPLAY'.
  ENDIF.
*&--------------------------------------------------------------------
*&      Form  GET_DATA
*&--------------------------------------------------------------------
*       text
*---------------------------------------------------------------------
FORM GET_DATA.
  SELECT *
    FROM VBRP
    INTO TABLE ITAB
    WHERE VBELN IN S_VBELN.

  IF SY-SUBRC = 0.
    V_FLAG = 'X'.
  ELSE.
    V_FLAG = SPACE.
  ENDIF.

ENDFORM.                    " GET_DATA
*&---------------------------------------------------------------------
*&      Form  VALIDATE_S_VBELN
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
FORM VALIDATE_S_VBELN.
  SELECT VBELN
    INTO VBRK-VBELN
    UP TO 1 ROWS
    FROM VBRK
    WHERE VBELN IN S_VBELN.
  ENDSELECT.
  IF SY-SUBRC <> 0.
    MESSAGE E004(ZBDC) WITH 'Invalid Range of VBELN From' S_VBELN-LOW
'And' S_VBELN-HIGH.
  ENDIF.
ENDFORM.                    " VALIDATE_S_VBELN
*&---------------------------------------------------------------------
*&      Form  VALIDATE_S_VKORG
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
FORM VALIDATE_S_VKORG.
  SELECT VKORG
    INTO TVKO-VKORG
    UP TO 1 ROWS
    FROM TVKO
    WHERE VKORG IN S_VKORG.
  ENDSELECT.
  IF SY-SUBRC <> 0.
    MESSAGE E004(ZBDC) WITH 'Invalid Range of VKORG From' S_VKORG-LOW
'And' S_VKORG-HIGH.
  ENDIF.
ENDFORM.                    " VALIDATE_S_VKORG
*&---------------------------------------------------------------------
*&      Form  VALIDATE_ALL
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
FORM VALIDATE_ALL.
*  IF S_VBELN IS INITIAL.
*    MESSAGE E004(ZBDC) WITH 'Pls Enter Billing Doc No'.
*  ENDIF.
*  IF S_VKORG IS INITIAL.
*    MESSAGE E004(ZBDC) WITH 'Pls Enter Valid Sales Org'.
*  ENDIF.
ENDFORM.                    " VALIDATE_ALL
*&---------------------------------------------------------------------
*&      Form  DISP_DATA
*&---------------------------------------------------------------------
*       text
*----------------------------------------------------------------------
FORM DISP_DATA.
LOOP AT ITAB.
 WRITE:/ SY-VLINE,
         ITAB-VBELN,
      15 SY-VLINE,
         ITAB-POSNR,
      25 SY-VLINE,
         ITAB-MATNR,
      43 SY-VLINE,
         ITAB-ARKTX,
      80 SY-VLINE,
         ITAB-SMENG,
     100 SY-VLINE.
ENDLOOP.
V_NO = ( SY-LINCT - SY-LINNO ).
SKIP V_NO.

ENDFORM.                    " DISP_DATA
*&---------------------------------------------------------------------*
*&      Form  BUILD_HEADER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM BUILD_HEADER.
 WRITE SY-ULINE(100).
 WRITE:/ SY-VLINE,
         'Billing Doc',
      15 SY-VLINE,
         'Line Item',
      25 SY-VLINE,
         'Material',
      43 SY-VLINE,
         'Material Desc',
      80 SY-VLINE,
         'Quantity',
     100 SY-VLINE.
WRITE SY-ULINE(100).
ENDFORM.                    " BUILD_HEADER
*&---------------------------------------------------------------------*
*&      Form  BUILD_FOOTER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM BUILD_FOOTER.
WRITE:/ SY-ULINE(100).
WRITE:/90 SY-PAGNO.
ENDFORM.                    " BUILD_FOOTER

No comments:

Post a Comment