Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

interactive report---urgent

Former Member
0 Kudos

hi gurus,

Can u check this program and can u tell me the correct code.Here iam getting the

1. material description is same for all the materials.and

2 when ever iam clicking on the secondary list the list repeating ...

3. when ever i will reach the secondary list i want to go back to first screen and ther i have to select one more field.Based on that field value again i want to generate secondary list .

the following is the program.

REPORT Z_MTRL_ANALY.

TABLES : QALS .

DATA : BEGIN OF ITAB OCCURS 2.

INCLUDE STRUCTURE QALS.

  • DATA MAKTX LIKE MAKT-MAKTX.

DATA : END OF ITAB.

DATA : BEGIN OF ITAB1 OCCURS 2.

INCLUDE STRUCTURE S022.

DATA MAKTX LIKE MAKT-MAKTX.

DATA : END OF ITAB1.

SELECT-OPTIONS : DATE FOR QALS-PASTRTERM.

SELECT PRUEFLOS SELMATNR ART AUFNR FROM QALS INTO CORRESPONDING FIELDS OF ITAB WHERE PASTRTERM IN DATE.

APPEND ITAB.

ENDSELECT.

LOOP AT ITAB.

SELECT MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF ITAB1 WHERE MATNR = ITAB-SELMATNR.

  • CLEAR ITAB1.

APPEND ITAB1.

ENDSELECT.

ENDLOOP.

LOOP AT ITAB.

WRITE : / ITAB-PRUEFLOS , ITAB-SELMATNR , ITAB1-MAKTX , ITAB-ART , ITAB-AUFNR.

HIDE ITAB-AUFNR.

ENDLOOP.

AT LINE-SELECTION.

SELECT VORNR ARBPL XMNGA FROM S022 INTO CORRESPONDING FIELDS OF ITAB1 WHERE AUFNR = ITAB-AUFNR.

APPEND ITAB1.

ENDSELECT.

LOOP AT ITAB1.

WRITE : / ITAB1-VORNR , ITAB1-ARBPL , ITAB1-XMNGA.

ENDLOOP.

IF SY-LSIND = 2.

SY-LSIND = 1.

HIDE ITAB-SELMATNR.

ENDIF.

2 REPLIES 2

Former Member
0 Kudos

Hi,

This code is incorrect:

LOOP AT ITAB.

SELECT MAKTX FROM MAKT INTO CORRESPONDING FIELDS OF ITAB1 WHERE MATNR = ITAB-SELMATNR.

  • CLEAR ITAB1.

APPEND ITAB1.

ENDSELECT.

ENDLOOP.

LOOP AT ITAB.

WRITE : / ITAB-PRUEFLOS , ITAB-SELMATNR , ITAB1-MAKTX , ITAB-ART , ITAB-AUFNR.

HIDE ITAB-AUFNR.

ENDLOOP.

Instead use like this:

SELECT matnr

maktx

FROM makt

INTO TABLE itab1

FOR ALL ENTRIES IN itab

WHERE matnr EQ itab-matnr.

SORT tab1 BY matnr.

LOOP AT itab.

CLEAR itab1.

READ TABLE itab1 WITH KEY matnr = itab-matnr BINARY SEARCH.

WRITE : / ITAB-PRUEFLOS , ITAB-SELMATNR , ITAB1-MAKTX , ITAB-ART , ITAB-AUFNR.

HIDE ITAB-AUFNR.

ENDLOOP.

Here, the table itab1 should have only two fields matnr and maktx.

2) This code is incorrect.

AT LINE-SELECTION.

SELECT VORNR ARBPL XMNGA FROM S022 INTO CORRESPONDING FIELDS OF ITAB1 WHERE AUFNR = ITAB-AUFNR.

APPEND ITAB1.

ENDSELECT.

LOOP AT ITAB1.

WRITE : / ITAB1-VORNR , ITAB1-ARBPL , ITAB1-XMNGA.

ENDLOOP.

IF SY-LSIND = 2.

SY-LSIND = 1.

HIDE ITAB-SELMATNR.

ENDIF.

Use this:

AT LINE-SELECTION.

IF SY-LSIND = 2.

SY-LSIND = 1.

HIDE ITAB-SELMATNR.

ELSE.

SELECT VORNR ARBPL XMNGA FROM S022 INTO CORRESPONDING FIELDS OF ITAB2 WHERE AUFNR = ITAB-AUFNR.

APPEND ITAB2.

ENDSELECT.

LOOP AT ITAB2.

WRITE : / ITAB2-VORNR , ITAB2-ARBPL , ITAB2-XMNGA.

ENDLOOP.

ENDIF.

Thanks and Best Regards,

Vikas Bittera.

Former Member
0 Kudos

Hello Sunder ,

Check the below code :

REPORT Z_MTRL_ANALY.

TABLES : QALS ,

makt.

DATA : BEGIN OF ITAB OCCURS 2.

INCLUDE STRUCTURE QALS.

DATA MAKTX LIKE MAKT-MAKTX.

DATA : END OF ITAB.

DATA : BEGIN OF ITAB1 OCCURS 2.

INCLUDE STRUCTURE S022.

DATA MAKTX LIKE MAKT-MAKTX.

DATA : END OF ITAB1.

data w_maktx like makt-maktx.

SELECT-OPTIONS : DATE FOR QALS-PASTRTERM.

start-of-selection.

SELECT PRUEFLOS SELMATNR ART AUFNR FROM QALS INTO CORRESPONDING FIELDS

OF ITAB WHERE PASTRTERM IN DATE.

APPEND ITAB.

ENDSELECT.

LOOP AT ITAB.

clear w_maktx.

SELECT single MAKTX FROM MAKT INTO w_maktx

WHERE MATNR = ITAB-SELMATNR

and spras = 'EN'.

.

if sy-subrc eq 0.

itab-maktx = w_maktx.

modify itab.

endif.

ENDLOOP.

LOOP AT ITAB.

HIDE ITAB-AUFNR.

WRITE : / ITAB-PRUEFLOS , ITAB-SELMATNR , ITAB-MAKTX , ITAB-ART ,

ITAB-AUFNR.

ENDLOOP.

end-of-selection.

AT LINE-SELECTION.

case sy-ucomm.

when 'PICK'.

SELECT VORNR ARBPL XMNGA FROM S022 INTO CORRESPONDING FIELDS OF ITAB1

WHERE AUFNR = ITAB-AUFNR.

APPEND ITAB1.

ENDSELECT.

LOOP AT ITAB1.

WRITE : / ITAB1-VORNR , ITAB1-ARBPL , ITAB1-XMNGA.

ENDLOOP.

IF SY-LSIND = 2.

SY-LSIND = 1.

HIDE ITAB-SELMATNR.

ENDIF.

endcase.

Please follow coding standards,do not use select endselect ,please use events properly like start-of-selection,end-of-selection.

I modified only few things ,now you will get material description and secondary list.

Thanks

Seshu