Application Development and Automation 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: 
Read only

print data by comparing fields

Former Member
0 Likes
517

hi all,

i have a itab in whch data is like this

matnr werks mfgnr

40 21 10

40 22 10

40 23 10

40 24 12

40 25 13

40 26 15

50 21 18

50 22 18

50 23 18

50 24 18

50 25 18

50 26 18

50 27 18

but in output i want to print only those mat where the mfgnr is not the same across all plants.that is output should be like this

matnr werks mfgnr

40 21 10

40 22 10

40 23 10

40 24 12

40 25 13

40 26 15.

output should not print any value of mat 50 as it is having same mfgnr for all palnts

mat 40 and 50 are entered in selection screen.

can anybody help.

<REMOVED BY MODERATOR>

thanks

sarabjit

Edited by: Alvaro Tejada Galindo on Jan 22, 2008 12:34 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
499

table two variable for matnr and mfgnr
code:
data: v_matnr like makt-matnr,
        v_mfgnr like makt-mfgnr.
data: lin1 like i, lin2 like i.

sort itab by matnr mfgnr.

read table itab index 1.

v_matnr = itab-matnr.
v_mfgnr = itab-mfgnr.

loop at itab.
at new matnr
  lin1 = sy-tabix.
endat.

at end matnr.
  lin2 = sy-tabix.
endat.
 if  v_matnr <> matnr or v_mfgnr <> mfgnr
   //read data from table itab line lin1 to lin2.
endif.
endloop.

Logic should be like this. add more statement to run it.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Jan 22, 2008 4:17 PM

4 REPLIES 4
Read only

Former Member
0 Likes
499

Hi

SORT ITAB BY MATNR WERKS MFGNR.

LOOP AT ITAB.
  AT NEW MATNR.
      FL_PRINT   = SPACE.
      FL_CHECK = 'X'.
  ENDAT.
   IF FL_CHECK = 'X'.
     LOOP AT ITAB TRANSPORTING NO FIELDS
                                WHERE MATNR  = ITAB-MATNR
                                      AND WERKS <> ITAB-WERKS
                                      AND MFGNR <> ITAB-MFGNR.
         EXIT.
     ENDLOOP.
     IF SY-SUBRC = 0.
        FL_PRINT = 'X'.
     ENDIF.
     CLEAR FL_CHECK.
   ENDIF.
   CHECK FL_PRINT = 'X'.
   WRITE: ITAB-MATNR, ITAB-WERKS, ITAB-MFGNR.
ENDLOOP.

Max

Edited by: max bianchi on Jan 22, 2008 6:42 PM

Read only

0 Likes
499

can u plz explain what is fl_print and fl_check in the code

thanks for reply. i m working on code suggested by you

thanks

ur suggested code is printing all the value of mat 40 and 5 but in my case i only reqiured to print the for mat 40 as it is having different values of mfgnr not mat 50 itis having same value of mfgnr all the way

any other suggestions plz

thanks

Edited by: sarabjit kaur on Jan 22, 2008 12:43 PM

Read only

0 Likes
499

FL_PRINT = SPACE.

FL_CHECK = 'X'.

fl_print and fl_check are simply local variables which used by check the condition where new matnr is fired by at new matnr commond.

Read only

Former Member
0 Likes
500

table two variable for matnr and mfgnr
code:
data: v_matnr like makt-matnr,
        v_mfgnr like makt-mfgnr.
data: lin1 like i, lin2 like i.

sort itab by matnr mfgnr.

read table itab index 1.

v_matnr = itab-matnr.
v_mfgnr = itab-mfgnr.

loop at itab.
at new matnr
  lin1 = sy-tabix.
endat.

at end matnr.
  lin2 = sy-tabix.
endat.
 if  v_matnr <> matnr or v_mfgnr <> mfgnr
   //read data from table itab line lin1 to lin2.
endif.
endloop.

Logic should be like this. add more statement to run it.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Jan 22, 2008 4:17 PM