Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

report checking

Hi abapers,

I have written this code. my code is going fine. but still i wanted to know what more changes i need to make in the code to make it more efficient and also i wanted to know where i have use <clear> and <refresh> statement in my program , frnds plzz guide me in doing so.

<code>

----


  • T A B L E S *

----


TABLES : KNA1, " CUSTOMER MASTER

VBAK, " SALES ORDER HEADER

VBAP, " SALES ORDER ITEM

SSCRFIELDS.

----


  • STRUCTURE DECLARATIONS

  • INTERNAL TABLE DECLARATIONS

  • WORK AREA DECLARATIONS

----


  • CUSTOMER

TYPES : BEGIN OF ST_KNA1,

KUNNR TYPE KNA1-KUNNR,

NAME1 TYPE KNA1-NAME1,

END OF ST_KNA1.

  • SALES ORDER HEADER

TYPES : BEGIN OF ST_VBAK,

VBELN TYPE VBAK-VBELN,

AUDAT TYPE VBAK-AUDAT,

VBTYP TYPE VBAK-VBTYP,

TRVOG TYPE VBAK-TRVOG,

AUART TYPE VBAK-AUART,

LIFSK TYPE VBAK-LIFSK,

FAKSK TYPE VBAK-FAKSK,

NETWR TYPE VBAK-NETWR,

KUNNR TYPE VBAK-KUNNR,

END OF ST_VBAK.

  • SALES ORDER ITEM

TYPES : BEGIN OF ST_VBAP,

VBELN TYPE VBAP-VBELN,

POSNR TYPE VBAP-POSNR,

NETWR TYPE VBAP-NETWR,

MATKL TYPE VBAP-MATKL,

ARKTX TYPE VBAP-ARKTX,

PSTYV TYPE VBAP-PSTYV,

MEINS TYPE VBAP-MEINS,

END OF ST_VBAP.

----


  • INTERNAL TABLE *

----


DATA : IT_KNA1 TYPE STANDARD TABLE OF ST_KNA1,

IT_VBAK TYPE STANDARD TABLE OF ST_VBAK,

IT_VBAP TYPE STANDARD TABLE OF ST_VBAP.

----


  • WORK AREA *

----


DATA : V_KNA1 LIKE LINE OF IT_KNA1,

V_VBAK LIKE LINE OF IT_VBAK,

V_VBAP LIKE LINE OF IT_VBAP.

*DATA : FNAME(20),

  • FVAL(15).

*DATA : F(30),WA(30).

----


  • LOAD OF PROGRAM *

----


LOAD-OF-PROGRAM.

----


  • SET PF-STATUS *

----


----


  • SELECTION SCREEN *

----


SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : SO_CUST FOR KNA1-KUNNR . "SELECT OPTIONS FOR CUSTOMER

PARAMETERS P_HITS TYPE I .

SELECTION-SCREEN END OF BLOCK B1.

AT SELECTION-SCREEN.

AT SELECTION-SCREEN ON SO_CUST.

----


  • SELECTION SCREEN VALIDATION

----


*SUBROUTINE FOR VALIDATION OF SELECTION FIELDS

PERFORM VALIDATE_CUST.

FORM VALIDATE_CUST.

IF SO_CUST[] IS NOT INITIAL.

SELECT SINGLE KUNNR FROM KNA1 INTO V_KNA1 WHERE KUNNR IN SO_CUST.

IF SY-SUBRC <> 0.

MESSAGE E000(ZNEW) WITH 'PLZ ENTER CORRECT CUSTOMER DOCUMENT NUMBER'.

ENDIF.

ENDIF.

ENDFORM. "VALIDATE_CUST

*

----


  • * START OF SELECTION.

----


TOP-OF-PAGE.

PERFORM TOP-PAGE.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM DISPLAY_LIST.

*----


  • Display secondary list.

*----


AT LINE-SELECTION.

SET PF-STATUS 'TEST'.

PERFORM GET_SECONDARY.

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA .

SELECT KUNNR

NAME1

FROM KNA1 UP TO P_HITS ROWS INTO TABLE IT_KNA1

WHERE KUNNR IN SO_CUST.

IF NOT IT_KNA1[] IS INITIAL.

SELECT VBELN

AUDAT

VBTYP

TRVOG

AUART

LIFSK

FAKSK

NETWR

KUNNR

FROM VBAK INTO TABLE IT_VBAK

FOR ALL ENTRIES IN IT_KNA1 WHERE KUNNR = IT_KNA1-KUNNR .

IF NOT IT_VBAK[] IS INITIAL.

SELECT VBELN

POSNR

NETWR

MATKL

ARKTX

PSTYV

MEINS

FROM VBAP INTO TABLE IT_VBAP

FOR ALL ENTRIES IN IT_VBAK

WHERE VBELN = IT_VBAK-VBELN.

ENDIF.

ENDIF.

ENDFORM.

&----


*& Form TOP-PAGE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM TOP-PAGE .

WRITE :/ 'CUSTOMER DETALS'.

WRITE :/ SY-ULINE.

WRITE :/01 'CUSTOMER NUMBER',

24 'CUSTOMER NAME'.

ENDFORM. " TOP-PAGE

&----


*& Form DISPLAY_LIST

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_LIST .

LOOP AT IT_KNA1 INTO WA_KNA1.

  • FORMAT HOTSPOT ON.

WRITE : /03 WA_KNA1-KUNNR,

24 WA_KNA1-NAME1.

HIDE WA_KNA1-KUNNR.

ENDLOOP.

ENDFORM. " DISPLAY_LIST

&----


*& Form GET_SECONDARY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_SECONDARY .

DATA: var(20).

GET CURSOR FIELD var.

IF var = 'WA_KNA1-KUNNR'.

IF SY-LSIND = 1.

PERFORM DISP_LIST1.

ENDIF.

ENDIF.

ENDFORM. "GET_SECONDARY

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'SO_DETAIL'.

PERFORM DISP_LIST2.

CLEAR IT_VBAP.

WHEN 'SO_DEL'.

WHEN 'SO_FLOW'.

PERFORM TRANS.

ENDCASE.

DATA: var(20).

GET CURSOR FIELD var.

IF var = 'WA_VBAK-VBELN'.

IF SY-LSIND = 2.

PERFORM DISP_LIST2.

ENDIF.

ENDIF.

*ENDFORM.

&----


*& Form TRANS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM TRANS .

DATA : F(30),WA(30).

GET CURSOR FIELD F VALUE WA_VBAP-VBELN.

IF F = 'WA_VBAK-VBELN'.

SET PARAMETER ID 'AUN' FIELD WA_VBAK-VBELN.

ENDIF.

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

ENDFORM. " TRANS

&----


*& Form DISP_LIST1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISP_LIST1 .

LOOP AT IT_VBAK INTO WA_VBAK WHERE KUNNR = WA_KNA1-KUNNR.

  • FORMAT HOTSPOT ON.

WRITE :/ WA_VBAK-VBELN,

WA_VBAK-AUDAT,

WA_VBAK-VBTYP,

WA_VBAK-TRVOG,

WA_VBAK-AUART,

WA_VBAK-LIFSK,

WA_VBAK-FAKSK,

WA_VBAK-NETWR,

WA_VBAK-KUNNR.

HIDE WA_VBAK-VBELN.

ENDLOOP.

*endif.

ENDFORM. " DISP_LIST1

&----


*& Form DISP_LIST2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISP_LIST2 .

LOOP AT IT_VBAP INTO WA_VBAP WHERE VBELN = WA_VBAK-VBELN.

WRITE :/ WA_VBAP-VBELN,

WA_VBAP-POSNR,

WA_VBAP-NETWR,

WA_VBAP-MATKL,

WA_VBAP-ARKTX,

WA_VBAP-PSTYV,

WA_VBAP-NETWR,

WA_VBAP-MEINS.

HIDE WA_VBAP-VBELN.

ENDLOOP.

ENDFORM.

</CODE>

Thanks,

karan

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question