Skip to Content
author's profile photo Former Member
Former Member

to get details after second list in interactive report

hai abap experts,

i got a problem, i have written acode in which 3rd list is not executing how to write code for 3rd list(my 3rd list is to get item details by call transaction 'me23')

i'll send u all my code lz check n help out.

TABLES : EKKO,

EKPO,

LFA1,

EKET.

SELECT-OPTIONS : S_LIFNR FOR EKKO-LIFNR,

S_BSART FOR EKKO-BSART,

S_AEDAT FOR EKKO-AEDAT.

************************************************************************

************************INTERNAL TABLES*******************************

************************************************************************

DATA : BEGIN OF RESULTS OCCURS 1000, "DATA RETRIEVAL RESULTS

LIFNR LIKE EKKO-LIFNR,

EBELN LIKE EKKO-EBELN,

EBELP LIKE EKPO-EBELP,

AEDAT LIKE EKKO-AEDAT,

ERNAM LIKE EKKO-ERNAM,

LINES(3) TYPE N,

NETWR LIKE EKPO-NETWR,

MENGE LIKE EKPO-MENGE,

WEMNG LIKE EKET-WEMNG,

TXZ01 LIKE EKPO-TXZ01,

END OF RESULTS.

DATA : BEGIN OF WRK, "WORK FIELD DEFINATIONS

HDRSW(1), "LIST HEADER SWITCH

TITLE2(40), "2ND TITLE LINE FOR REPORT

END OF WRK.

DATA : BEGIN OF SELECT, "USER SELECTION FIELDS

EBELN LIKE EKKO-EBELN, "PURCHASE ORDER NO

CHECKBOX(1) TYPE C,

END OF SELECT.

DATA : BEGIN OF STATS, "STATISTICS

START_TIME LIKE SY-UZEIT,

END_TIME LIKE SY-UZEIT,

PROC_TIME LIKE SY-UZEIT,

RECS_EKPO LIKE SY-DBCNT,

RECS_EKKO LIKE SY-DBCNT,

END OF STATS.

************************************************************************

**************************EVENTS**************************************

************************************************************************

INITIALIZATION.

CLEAR S_AEDAT.

S_AEDAT-SIGN = 'I'.

S_AEDAT-OPTION = 'BT'.

S_AEDAT-LOW = SY-DATUM - 30.

S_AEDAT-HIGH = SY-DATUM.

APPEND S_AEDAT.

AT SELECTION-SCREEN.

LOOP AT S_LIFNR.

CHECK S_LIFNR-OPTION = 'EQ'.

SELECT SINGLE * FROM LFA1 WHERE LIFNR = S_LIFNR-LOW.

IF SY-SUBRC NE 0.

MESSAGE E002 WITH 'VENDOR' S_LIFNR-LOW 'NOT FOUND IN LFA1'.

ENDIF.

ENDLOOP.

START-OF-SELECTION.

GET TIME.

STATS-START_TIME = SY-UZEIT.

SET PF-STATUS 'MAIN'.

PERFORM DATA_RETRIEVAL.

PERFORM PROCESS_DATA.

PERFORM DISPLAY_LIST.

PERFORM WRITE_SELECTIONS.

PERFORM WRITE_STATISTICS.

AT LINE-SELECTION.

CHECK NOT SELECT-EBELN IS INITIAL.

PERFORM DISPLAY_ITEM_DETAIL USING SELECT-EBELN.

CLEAR : SELECT-EBELN.

AT USER-COMMAND.

CASE SY-UCOMM.

WHEN 'DSA'.

PERFORM CLEAR_ALL_SELECTED.

WHEN 'DSL'.

PERFORM DISPLAY_ALL_SELECTED.

ENDCASE.

TOP-OF-PAGE.

CASE WRK-HDRSW.

WHEN '1'.

WRK-TITLE2 = 'PROGRAM SELECTIONS'(002).

WHEN '2'.

WRK-TITLE2 = 'PROGRAM DETAIL'(003).

WHEN '3'.

WRK-TITLE2 = 'PROGRAM SUMMARY'(004).

WHEN '4'.

WRK-TITLE2 = 'PROGRAM STATISTICS'(005).

ENDCASE.

FORMAT COLOR COL_HEADING.

PERFORM PGH_STANDARD_HEADING

USING TEXT-001

WRK-TITLE2.

IF WRK-HDRSW = '2'.

WRITE : /01 SY-VLINE,

02 'VENDOR #'(103),

16 SY-VLINE,

17 'PO #'(104),

32 SY-VLINE,

33 'ENTRY DATE'(105),

43 SY-VLINE,

44 'USER'(106),

59 SY-VLINE,

60 'LINES'(107),

70 SY-VLINE,

71 'AMOUNT'(108),

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

ENDIF.

FORMAT RESET.

************************************************************************

**************************SECONDRY LIST*******************************

************************************************************************

TOP-OF-PAGE DURING LINE-SELECTION.

CASE WRK-HDRSW.

WHEN '5'.

WRK-TITLE2 = 'DETAIL LISTING'(201).

ENDCASE.

FORMAT COLOR COL_HEADING.

PERFORM PGH_STANDARD_HEADING

USING TEXT-001

WRK-TITLE2.

IF WRK-HDRSW = '5'.

WRITE : /01 SY-VLINE,

02 'VENDOR #'(103),

16 SY-VLINE,

17 'PO #'(104),

32 SY-VLINE,

33 'ENTRY DATE'(105),

43 SY-VLINE,

44 'USER'(106),

59 SY-VLINE.

WRITE : /01 SY-ULINE(59).

FORMAT COLOR COL_KEY.

WRITE : /01 SY-VLINE,

02 RESULTS-LIFNR,

16 SY-VLINE,

17 RESULTS-EBELN,

32 SY-VLINE,

33 RESULTS-AEDAT DD/MM/YY,

43 SY-VLINE,

44 RESULTS-ERNAM,

59 SY-VLINE.

WRITE : /01 SY-ULINE(101).

FORMAT COLOR COL_HEADING.

WRITE : /01 SY-VLINE,

02 'LINE'(301),

07 SY-VLINE,

08 'DESCRIPTION'(302),

48 SY-VLINE,

49 'QTY ORDERDED'(303),

64 SY-VLINE,

65 'QTY RECEIVED'(304),

80 SY-VLINE,

81 'AMOUNT'(305),

101 SY-VLINE.

WRITE : /01 SY-ULINE(101).

ENDIF.

FORMAT RESET.

************************************************************************

*************************SUBROUTINES**********************************

************************************************************************

FORM DISPLAY_ALL_SELECTED.

DATA : LINE_NUMBER LIKE SY-LILLI.

LINE_NUMBER = 1.

DO.

CLEAR : SELECT-CHECKBOX,

SELECT-EBELN.

READ LINE LINE_NUMBER FIELD VALUE SELECT-CHECKBOX

SELECT-EBELN.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

ADD 1 TO LINE_NUMBER.

CHECK SELECT-CHECKBOX = 'X'.

NEW-PAGE.

PERFORM DISPLAY_ITEM_DETAIL USING SELECT-EBELN.

ENDDO.

ENDFORM.

***********************************************************************

FORM CLEAR_ALL_SELECTED.

DATA : LINE_NUMBER LIKE SY-LILLI.

LINE_NUMBER = 1.

DO.

READ LINE LINE_NUMBER FIELD VALUE SELECT-CHECKBOX

SELECT-EBELN.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

IF SELECT-CHECKBOX = 'X'.

CLEAR : SELECT-CHECKBOX.

MODIFY LINE LINE_NUMBER FIELD VALUE SELECT-CHECKBOX

SELECT-EBELN.

ENDIF.

ADD 1 TO LINE_NUMBER.

ENDDO.

ENDFORM.

************************************************************************

FORM DATA_RETRIEVAL.

SELECT * FROM EKKO WHERE BSART IN S_BSART

AND AEDAT IN S_AEDAT

AND LIFNR IN S_LIFNR.

CLEAR RESULTS.

RESULTS-LIFNR = EKKO-LIFNR.

RESULTS-EBELN = EKKO-EBELN.

RESULTS-AEDAT = EKKO-AEDAT.

RESULTS-ERNAM = EKKO-ERNAM.

SELECT * FROM EKPO WHERE EBELN = EKKO-EBELN.

MOVE 1 TO RESULTS-LINES.

MOVE EKPO-NETWR TO RESULTS-NETWR.

RESULTS-EBELP = EKPO-EBELP.

RESULTS-TXZ01 = EKPO-TXZ01.

RESULTS-MENGE = EKPO-MENGE.

APPEND RESULTS.

ENDSELECT.

ENDSELECT.

ENDFORM. "DATA_RETRIEVAL

************************************************************************

FORM PROCESS_DATA.

LOOP AT RESULTS.

CLEAR RESULTS-WEMNG.

SELECT * FROM EKET WHERE EBELN = RESULTS-EBELN

AND EBELP = RESULTS-EBELP.

ADD EKET-WEMNG TO RESULTS-WEMNG.

ENDSELECT.

MODIFY RESULTS.

ENDLOOP.

ENDFORM. "PROCESS_DATA

************************************************************************

FORM DISPLAY_LIST.

DATA : TOT_LINES(3) TYPE N.

DATA : TOT_AMT LIKE EKPO-NETWR.

DATA : WRT_FLAG(1) TYPE C.

SORT RESULTS BY LIFNR EBELN.

NEW-PAGE.

WRK-HDRSW = '2'.

LOOP AT RESULTS.

AT END OF EBELN.

MOVE 'X' TO WRT_FLAG.

ENDAT.

ADD 1 TO TOT_LINES.

ADD RESULTS-NETWR TO TOT_AMT.

IF WRT_FLAG = 'X'.

WRITE : /01 SY-VLINE,

02 SELECT-CHECKBOX AS CHECKBOX,

04 RESULTS-LIFNR,

16 SY-VLINE,

17 RESULTS-EBELN,

32 SY-VLINE,

33 RESULTS-AEDAT MM/DD/YY,

43 SY-VLINE,

44 RESULTS-ERNAM,

59 SY-VLINE,

60 TOT_LINES,

70 SY-VLINE,

71 TOT_AMT,

91 SY-VLINE.

SELECT-EBELN = RESULTS-EBELN.

HIDE : SELECT-EBELN.

CLEAR : SELECT-EBELN.

WRITE : /01 SY-ULINE(91).

CLEAR : WRT_FLAG,

TOT_LINES,

TOT_AMT.

ENDIF.

AT END OF LIFNR.

SUM.

FORMAT COLOR COL_GROUP.

WRITE : /01 SY-VLINE,

02 'TOTAL FOR VENDOR:'(101),

RESULTS-LIFNR,

70 SY-VLINE,

71 RESULTS-NETWR,

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

FORMAT RESET.

ENDAT.

ENDLOOP.

IF SY-SUBRC NE 0.

FORMAT COLOR COL_NEGATIVE.

WRITE : /01 SY-VLINE,

02 'NO RECORDS FOUND'(102),

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

FORMAT RESET.

ENDIF.

ENDFORM. "DISPLAY_LIST

************************************************************************

FORM DISPLAY_ITEM_DETAIL USING L_EBELN.

CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.

SET PARAMETER ID 'BES' FIELD L_EBELN.

*GET PARAMETER ID 'BES' FIELD L_EBELN.

WRK-HDRSW = '5'.

SET PF-STATUS 'STLI'.

LOOP AT RESULTS WHERE EBELN = L_EBELN.

WRITE : /01 SY-VLINE,

02 RESULTS-EBELP,

07 SY-VLINE,

08 RESULTS-TXZ01,

48 SY-VLINE,

49(15) RESULTS-MENGE,

64 SY-VLINE,

65(15) RESULTS-WEMNG,

80 SY-VLINE,

81 RESULTS-NETWR,

101 SY-VLINE.

WRITE : /01 SY-ULINE(101).

ENDLOOP.

IF SY-SUBRC NE 0.

FORMAT COLOR COL_NEGATIVE.

WRITE : /01 SY-VLINE,

02 'NO RECORDS FOUND'(102),

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

FORMAT RESET.

ENDIF.

ENDFORM. "DISPLAY_ITEM_DETAIL

************************************************************************

FORM WRITE_SELECTIONS.

NEW-PAGE.

WRK-HDRSW = '1'.

WRITE : /01 SY-VLINE,

02 'VENDOR NUMBER'(112),

25 SY-VLINE.

LOOP AT S_LIFNR.

WRITE : 26 S_LIFNR,

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

ENDLOOP.

IF SY-SUBRC NE 0.

WRITE : 26 '*ALL*'(200),

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

ENDIF.

WRITE : /01 SY-VLINE,

02 'PO TYPE'(111),

25 SY-VLINE.

LOOP AT S_BSART.

WRITE : 26 S_BSART,

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

ENDLOOP.

IF SY-SUBRC NE 0.

WRITE : 26 '*ALL*'(200),

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

ENDIF.

WRITE : /01 SY-VLINE,

02 'ENTRY DATES'(112),

25 SY-VLINE.

LOOP AT S_AEDAT.

WRITE : 26 S_AEDAT,

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

ENDLOOP.

IF SY-SUBRC NE 0.

WRITE : 26 '*ALL*'(200),

91 SY-VLINE.

WRITE : / SY-ULINE(91).

ENDIF.

ENDFORM. "WRITE_SELECTIONS

************************************************************************

FORM WRITE_STATISTICS.

NEW-PAGE.

WRK-HDRSW = '4'.

GET TIME.

STATS-END_TIME = SY-UZEIT.

IF STATS-END_TIME > STATS-START_TIME.

STATS-PROC_TIME = STATS-END_TIME - STATS-START_TIME.

ELSE.

STATS-PROC_TIME = '240000'.

STATS-PROC_TIME = STATS-PROC_TIME - STATS-START_TIME.

STATS-PROC_TIME = STATS-PROC_TIME + STATS-END_TIME.

ENDIF.

WRITE : /01 SY-VLINE,

02 'START TIME'(113),

25 SY-VLINE,

26 STATS-START_TIME USING EDIT MASK '__:__:__',

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

WRITE : /01 SY-VLINE,

02 'END TIME'(114),

25 SY-VLINE,

26 STATS-END_TIME USING EDIT MASK '__:__:__',

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

WRITE : /01 SY-VLINE,

02 'PROCESSING TIME'(115),

25 SY-VLINE,

26 STATS-PROC_TIME USING EDIT MASK '__:__:__',

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

WRITE : /01 SY-VLINE,

02 'EKKO RECORDS READ'(116),

25 SY-VLINE,

26 STATS-RECS_EKKO,

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

WRITE : /01 SY-VLINE,

02 'EKPO RECORDS READ'(117),

25 SY-VLINE,

26 STATS-RECS_EKPO,

91 SY-VLINE.

WRITE : /01 SY-ULINE(91).

ENDFORM. "WRITE_STATISTICS

***********************************************************************

***********************************************************************

FORM PGH_STANDARD_HEADING USING L_TITLE1

L_TITLE2.

FORMAT COLOR COL_HEADING.

PERFORM PGH_WRITE_DATE_TIME.

PERFORM PGH_WRITE_TITLE USING L_TITLE1.

PERFORM PGH_WRITE_REPORT_PAGE.

PERFORM PGH_WRITE_USERID.

PERFORM PGH_WRITE_TITLE USING L_TITLE2.

PERFORM PGH_WRITE_SYSTEM_CLIENT.

FORMAT RESET.

ENDFORM. "PGH_STANDARD_HEADING

***********************************************************************

FORM PGH_WRITE_USERID.

WRITE : /01 SY-ULINE(91).

WRITE : /01 SY-VLINE,

02 'USERID:',

10 SY-UNAME,

91 SY-VLINE.

ENDFORM. "PGH_WRITE_USERID

***********************************************************************

FORM PGH_WRITE_DATE_TIME.

WRITE : /01 SY-ULINE(91).

WRITE : /01 SY-VLINE,

02 'DATE:',

10 SY-DATUM MM/DD/YYYY,

21 '/',

23 SY-UZEIT USING EDIT MASK'__:__:__',

91 SY-VLINE.

ENDFORM. "PGH_WRITE_DATE_TIME

***********************************************************************

FORM PGH_WRITE_TITLE USING L_TITLE.

DATA : L_LINSZ LIKE SY-LINSZ.

DATA : L_TITLEL LIKE SY-TABIX.

DATA : L_START LIKE SY-TABIX.

L_LINSZ = SY-LINSZ.

L_TITLEL = STRLEN( L_TITLE ).

L_START = ( L_LINSZ / 2 ) - ( L_TITLEL / 2 ).

POSITION L_START.

WRITE :/01 SY-VLINE,

02 L_TITLE,

91 SY-VLINE.

ENDFORM. "PGH_WRITE_TITLE

***********************************************************************

FORM PGH_WRITE_REPORT_PAGE.

DATA : L_LINSZ LIKE SY-LINSZ.

DATA : L_START LIKE SY-TABIX.

L_LINSZ = SY-LINSZ.

L_START = L_LINSZ - 24.

POSITION L_START.

WRITE : /01 SY-VLINE,

02 'REPORT:', SY-REPID, 'PG', (4) SY-PAGNO,

91 SY-VLINE.

POSITION L_LINSZ.

ENDFORM. "PGH_WRITE_REPORT_PAGE

************************************************************************

FORM PGH_WRITE_SYSTEM_CLIENT.

DATA : L_LINSZ LIKE SY-LINSZ.

DATA : L_START LIKE SY-TABIX.

L_LINSZ = SY-LINSZ.

L_START = L_LINSZ - 24.

POSITION L_START.

WRITE :/01 SY-VLINE,

02 'SYSTEM:', SY-SYSID,'/',SY-MANDT,

91 SY-VLINE.

POSITION L_LINSZ.

  • WRITE :/01 SY-VLINE.

WRITE : /01 SY-ULINE(91).

ENDFORM. "PGH_WRITE_SYSTEM_CLIENT

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Dec 03, 2007 at 04:02 PM

    You need to put the code for all secondary lists in the AT LINE-SELECTION (if you use the double clik) or AT USER-COMMAND(if you use the button go generate the list).

    Try to debug by setting brekpoint in the event AT LINE-SELECTION and AT USER-COMMAND.

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 04:08 PM

    There is a very minor correction in your logic.

    FORM DISPLAY_ITEM_DETAIL USING L_EBELN.

    CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.

    SET PARAMETER ID 'BES' FIELD L_EBELN.

    *GET PARAMETER ID 'BES' FIELD L_EBELN.

    instead of this try

    SET PARAMETER ID 'BES' FIELD L_EBELN.

    CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.

    you should always set the parameter id first and then call the transaction.

    i tried it in my system and it seems to be working.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 04:10 PM

    Hi Rajesh,

    Did you write PICK in front of function key F2 in status 'MAIN'. if you din't write navigation won't work...

    because with in same program you are using AT LINE-SELECTION & AT USER-COMMAND...

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.