11-11-2008 3:59 AM
Hi,
I am working on a code and it is giving problem that where the Work center field is empty it is making the last field repeated having the Work Center . here 's d code :-
LOOP AT T_MAPL INTO W_MAPL.
LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR.
W_FTAB6-PLNKN = W_PLAS-PLNKN.
LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN.
W_FTAB6-MATNR = W_MAPL-MATNR.
W_FTAB6-PLNTY = W_MAPL-PLNTY.
W_FTAB6-PLNAL = W_MAPL-PLNAL.
W_FTAB6-WERKS = W_MAPL-WERKS.
READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR.
W_FTAB6-KTEXT = W_PLKO-KTEXT.
W_FTAB6-PLNNR = W_PLPO-PLNNR.
W_FTAB6-VORNR = W_PLPO-VORNR.
W_FTAB6-LTXA1 = W_PLPO-LTXA1.
W_FTAB6-KTSCH = W_PLPO-KTSCH.
W_FTAB6-ARBID = W_PLPO-ARBID.
W_FTAB6-BMSCH = W_PLPO-BMSCH.
W_FTAB6-MEINH = W_PLPO-MEINH.
W_FTAB6-VGW04 = W_PLPO-VGW04.
W_FTAB6-VGE04 = W_PLPO-VGE04.
READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
W_FTAB6-ARBPL = W_CRHD-ARBPL.
W_FTAB6-VERWE = W_CRHD-VERWE.
W_FTAB6-OBJTY = W_CRHD-OBJTY.
W_FTAB6-OBJID = W_CRHD-OBJID.
READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID.
W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP.
READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR.
W_FTAB6-LGPRO = W_MARC-LGPRO.
APPEND W_FTAB6 TO T_FTAB6.
ENDLOOP.
ENDLOOP.
ENDLOOP.
Plzz provide me guidlines that how should i remove the filling of the records which does not have the Work Center. (ARBPL)
11-11-2008 5:12 AM
LOOP AT T_MAPL INTO W_MAPL. LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR. W_FTAB6-PLNKN = W_PLAS-PLNKN. LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN. W_FTAB6-MATNR = W_MAPL-MATNR. W_FTAB6-PLNTY = W_MAPL-PLNTY. W_FTAB6-PLNAL = W_MAPL-PLNAL. W_FTAB6-WERKS = W_MAPL-WERKS. READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR. W_FTAB6-KTEXT = W_PLKO-KTEXT. W_FTAB6-PLNNR = W_PLPO-PLNNR. W_FTAB6-VORNR = W_PLPO-VORNR. W_FTAB6-LTXA1 = W_PLPO-LTXA1. W_FTAB6-KTSCH = W_PLPO-KTSCH. W_FTAB6-ARBID = W_PLPO-ARBID. W_FTAB6-BMSCH = W_PLPO-BMSCH. W_FTAB6-MEINH = W_PLPO-MEINH. W_FTAB6-VGW04 = W_PLPO-VGW04. W_FTAB6-VGE04 = W_PLPO-VGE04. READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID. If Sy-subrc NE 0. "if no matching record found Exit. "Exit loop without appending the record Endif. W_FTAB6-ARBPL = W_CRHD-ARBPL. W_FTAB6-VERWE = W_CRHD-VERWE. W_FTAB6-OBJTY = W_CRHD-OBJTY. W_FTAB6-OBJID = W_CRHD-OBJID. READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID. W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP. READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR. W_FTAB6-LGPRO = W_MARC-LGPRO. APPEND W_FTAB6 TO T_FTAB6. ENDLOOP. ENDLOOP. ENDLOOP.
Plzz provide me guidlines that how should i remove the filling of the records which does not have the Work Center. (ARBPL)
This will avoid appending of fields without a work center. Check this and revert back.
Regards
Karthik D
11-11-2008 4:05 AM
Hi,
I don;t know the work center field name.......
If the value is fetched through read statement, then check for sy-subrc.
if sy-subrc eq 0.
pass the work center value
else.
clear that field.
endif.
If the value is fetched through loop statement, then at the end of every loop pass, clear that workarea field.
-SatyaPriya
11-11-2008 4:07 AM
Hi,
u have to clear the field after before the endloop.
LOOP AT T_MAPL INTO W_MAPL.
LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR.
W_FTAB6-PLNKN = W_PLAS-PLNKN.
LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN.
W_FTAB6-MATNR = W_MAPL-MATNR.
W_FTAB6-PLNTY = W_MAPL-PLNTY.
W_FTAB6-PLNAL = W_MAPL-PLNAL.
W_FTAB6-WERKS = W_MAPL-WERKS.
READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR.
W_FTAB6-KTEXT = W_PLKO-KTEXT.
W_FTAB6-PLNNR = W_PLPO-PLNNR.
W_FTAB6-VORNR = W_PLPO-VORNR.
W_FTAB6-LTXA1 = W_PLPO-LTXA1.
W_FTAB6-KTSCH = W_PLPO-KTSCH.
W_FTAB6-ARBID = W_PLPO-ARBID.
W_FTAB6-BMSCH = W_PLPO-BMSCH.
W_FTAB6-MEINH = W_PLPO-MEINH.
W_FTAB6-VGW04 = W_PLPO-VGW04.
W_FTAB6-VGE04 = W_PLPO-VGE04.
READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
W_FTAB6-ARBPL = W_CRHD-ARBPL.
W_FTAB6-VERWE = W_CRHD-VERWE.
W_FTAB6-OBJTY = W_CRHD-OBJTY.
W_FTAB6-OBJID = W_CRHD-OBJID.
READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID.
W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP.
READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR.
W_FTAB6-LGPRO = W_MARC-LGPRO.
APPEND W_FTAB6 TO T_FTAB6.
*"-----------------------------
CLEAR: W_PLKO,
W_CRHD,
W_CRTX,
W_MARC,
W_FTAB6.
*"-----------------------------
ENDLOOP.
ENDLOOP.
ENDLOOP.
11-11-2008 4:33 AM
hi,
I am using the Refresh after the loops and it is still displaying the same data .if i use clear/refresh inside the loop it is not displaying the correct data.
ARBPL "Work center
VERWE "Work center cat.
OBJTY "Object types of the CIM resource
OBJID "Object ID of the resource
11-11-2008 4:49 AM
Actually, when u read a table into a work area.. it happens that, the data is copied from a row in the table to the work area...
and if u do not clear this work area, this value remains through out the scope of the wa.
so in ur case if u do not clear it befor the next loop pass, the old value remains...
u can do one thing... use Debugger and see what is happening....
regards
Sukriti...
11-11-2008 5:00 AM
Hi,
Use Below code, hope it will help u..
LOOP AT T_MAPL INTO W_MAPL.
W_FTAB6-MATNR = W_MAPL-MATNR.
W_FTAB6-PLNTY = W_MAPL-PLNTY.
W_FTAB6-PLNAL = W_MAPL-PLNAL.
W_FTAB6-WERKS = W_MAPL-WERKS.
LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR.
W_FTAB6-PLNKN = W_PLAS-PLNKN.
LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN.
W_FTAB6-PLNNR = W_PLPO-PLNNR.
W_FTAB6-VORNR = W_PLPO-VORNR.
W_FTAB6-LTXA1 = W_PLPO-LTXA1.
W_FTAB6-KTSCH = W_PLPO-KTSCH.
W_FTAB6-ARBID = W_PLPO-ARBID.
W_FTAB6-BMSCH = W_PLPO-BMSCH.
W_FTAB6-MEINH = W_PLPO-MEINH.
W_FTAB6-VGW04 = W_PLPO-VGW04.
W_FTAB6-VGE04 = W_PLPO-VGE04.
READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR.
IF SY-SUBRC = 0.
W_FTAB6-KTEXT = W_PLKO-KTEXT.
ENDIF.
READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
IF SY-SUBRC = 0.
W_FTAB6-ARBPL = W_CRHD-ARBPL.
W_FTAB6-VERWE = W_CRHD-VERWE.
W_FTAB6-OBJTY = W_CRHD-OBJTY.
W_FTAB6-OBJID = W_CRHD-OBJID.
ENDIF.
READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID.
IF SY-SUBRC = 0.
W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP.
ENDIF.
READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR.
IF SY-SUBRC = 0.
W_FTAB6-LGPRO = W_MARC-LGPRO.
ENDIF.
APPEND W_FTAB6 TO T_FTAB6.
ENDLOOP.
ENDLOOP.
ENDLOOP.
Regards,
Meet Gohel
11-11-2008 4:48 AM
Hi,
I think your problem will be solved with staypriyas solution. Check for sy-subrc after each read statement. For ex:
READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
if sy-subrc eq 0.
W_FTAB6-ARBPL = W_CRHD-ARBPL.
W_FTAB6-VERWE = W_CRHD-VERWE.
W_FTAB6-OBJTY = W_CRHD-OBJTY.
W_FTAB6-OBJID = W_CRHD-OBJID.
endif.
Regards,
Swarna Munukoti.
Edited by: Swarna Munukoti on Nov 11, 2008 5:48 AM
11-11-2008 5:12 AM
LOOP AT T_MAPL INTO W_MAPL. LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR. W_FTAB6-PLNKN = W_PLAS-PLNKN. LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN. W_FTAB6-MATNR = W_MAPL-MATNR. W_FTAB6-PLNTY = W_MAPL-PLNTY. W_FTAB6-PLNAL = W_MAPL-PLNAL. W_FTAB6-WERKS = W_MAPL-WERKS. READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR. W_FTAB6-KTEXT = W_PLKO-KTEXT. W_FTAB6-PLNNR = W_PLPO-PLNNR. W_FTAB6-VORNR = W_PLPO-VORNR. W_FTAB6-LTXA1 = W_PLPO-LTXA1. W_FTAB6-KTSCH = W_PLPO-KTSCH. W_FTAB6-ARBID = W_PLPO-ARBID. W_FTAB6-BMSCH = W_PLPO-BMSCH. W_FTAB6-MEINH = W_PLPO-MEINH. W_FTAB6-VGW04 = W_PLPO-VGW04. W_FTAB6-VGE04 = W_PLPO-VGE04. READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID. If Sy-subrc NE 0. "if no matching record found Exit. "Exit loop without appending the record Endif. W_FTAB6-ARBPL = W_CRHD-ARBPL. W_FTAB6-VERWE = W_CRHD-VERWE. W_FTAB6-OBJTY = W_CRHD-OBJTY. W_FTAB6-OBJID = W_CRHD-OBJID. READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID. W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP. READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR. W_FTAB6-LGPRO = W_MARC-LGPRO. APPEND W_FTAB6 TO T_FTAB6. ENDLOOP. ENDLOOP. ENDLOOP.
Plzz provide me guidlines that how should i remove the filling of the records which does not have the Work Center. (ARBPL)
This will avoid appending of fields without a work center. Check this and revert back.
Regards
Karthik D
11-11-2008 5:25 AM
hi karthik,
i had done the change as u had said and now it is displaying the data only where work centers are located but i want to display the data also where work center are not located. previously it was displaying the data of last work center repeatedly in the columns where work center is not defined but after making amendment it is showing the records where work center is present.
Edited by: ricx .s on Nov 11, 2008 6:39 AM
11-11-2008 5:39 AM
If you want the data for which work centers are not present then just delete what i have suggested. Check and revert back.
But your requirement is confusing, at first you told you dont want records which dont have workcenter.
Regards
Karthik D
11-11-2008 5:56 AM
hi ,
ok,i had removed the new code which you had said,i am really sorry that i got confused. Actually my requierment is :-
OprID W.C. Item description
0010 1422 SHEARING MACHINE-01
0011 1920 LATHE MACHINE N55
0015 1920 LATHE MACHINE N55
0020 1461 KNUCKLE JOINT PRASS -01
0021 1920 LATHE MACHINE N55
0025 1920 LATHE MACHINE N55
0030 1464 PEDESTAL GRINDER-01
0040 1461 KNUCKLE JOINT PRASS -01
0041 1920 LATHE MACHINE N55
0045 1920 LATHE MACHINE N55
0050 1920 LATHE MACHINE N55
This is the piece of output i am getting right now . There is WOrk center Id '1920' which is getting repeated for the values where no work center is defined and i want to display the as it is shown in the tcode CA03(Display Routing). I had checked in the debug mode that it is picking up the records where the Work Center is defined,and then it is picking the records where no work center is defined.
due to append statement it is picking the last record having work center value 1920 and it is making repetition of it for the records having no work center.
the output which i want to display is:-
OprID W.C. Item description
0010 1422 SHEARING MACHINE-01
0011
0015
0020 1461 KNUCKLE JOINT PRASS -01
0021
0025
0030 1464 PEDESTAL GRINDER-01
0040 1461 KNUCKLE JOINT PRASS -01
0041
0045
0050 1920 LATHE MACHINE N55
Plz provide me guidelines how to display this type of output.
11-11-2008 6:09 AM
LOOP AT T_MAPL INTO W_MAPL.
LOOP AT T_PLAS INTO W_PLAS WHERE PLNAL = W_MAPL-PLNAL AND PLNNR = W_MAPL-PLNNR.
W_FTAB6-PLNKN = W_PLAS-PLNKN.
LOOP AT T_PLPO INTO W_PLPO WHERE PLNNR = W_PLAS-PLNNR AND PLNKN = W_PLAS-PLNKN.
W_FTAB6-MATNR = W_MAPL-MATNR.
W_FTAB6-PLNTY = W_MAPL-PLNTY.
W_FTAB6-PLNAL = W_MAPL-PLNAL.
W_FTAB6-WERKS = W_MAPL-WERKS.
READ TABLE T_PLKO INTO W_PLKO WITH KEY PLNAL = W_MAPL-PLNAL PLNNR = W_MAPL-PLNNR.
W_FTAB6-KTEXT = W_PLKO-KTEXT.
W_FTAB6-PLNNR = W_PLPO-PLNNR.
W_FTAB6-VORNR = W_PLPO-VORNR.
W_FTAB6-LTXA1 = W_PLPO-LTXA1.
W_FTAB6-KTSCH = W_PLPO-KTSCH.
W_FTAB6-ARBID = W_PLPO-ARBID.
W_FTAB6-BMSCH = W_PLPO-BMSCH.
W_FTAB6-MEINH = W_PLPO-MEINH.
W_FTAB6-VGW04 = W_PLPO-VGW04.
W_FTAB6-VGE04 = W_PLPO-VGE04.
READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
If Sy-subrc EQ 0. "if a matching record found, proceed
W_FTAB6-ARBPL = W_CRHD-ARBPL.
W_FTAB6-VERWE = W_CRHD-VERWE.
W_FTAB6-OBJTY = W_CRHD-OBJTY.
W_FTAB6-OBJID = W_CRHD-OBJID.
READ TABLE T_CRTX INTO W_CRTX WITH KEY OBJID = W_CRHD-OBJID.
W_FTAB6-KTEXT_UP = W_CRTX-KTEXT_UP.
READ TABLE T_MARC INTO W_MARC WITH KEY MATNR = W_MAPL-MATNR.
W_FTAB6-LGPRO = W_MARC-LGPRO.
Endif. "if ends here
APPEND W_FTAB6 TO T_FTAB6.
Clear : W_PLPO, W_FTAB6, W_PLKO, W_CRHD, W_CRTX, W_MARC. "clear workareas used in this loop
ENDLOOP.
CLear W_PLAS. "clear workarea used in this loop
ENDLOOP.
Clear W_MAPL. "clear workarea used in this loop
ENDLOOP.
Do the corrections and check it.
Regards
Karthik D
11-11-2008 6:23 AM
hi karthik,
I am really thankful to you as the problem had been solved, i am assigning u full 10 points for it for providing me guidelines for solving this problem.
11-11-2008 5:45 AM
Do the following correction:
READ TABLE T_CRHD INTO W_CRHD WITH KEY OBJID = W_PLPO-ARBID.
if sy-subrc = 0.
W_FTAB6-ARBPL = W_CRHD-ARBPL.
W_FTAB6-VERWE = W_CRHD-VERWE.
W_FTAB6-OBJTY = W_CRHD-OBJTY.
W_FTAB6-OBJID = W_CRHD-OBJID.
endif.
This should solve your problem.
Regards,
Prakash Pandey