2016 Sep 13 2:05 PM
Hello,
I have one function module in which the table parameter 'ABC' is defined of type LTAP_VB.
This Parameter 'ABC' is already filled with different material types(MTART) like 'XYZ', 'SDF' etc and other data.
In my source code of the FM, i have a logic as below:
loop at ABC into wa_abc.
select * from mara where matnr = wa_abc-matnr and (mtart = 'XYZ' or mtart = 'SDF').
endloop.
then i need to create an idoc only for the materials which have MTART as 'XYZ' and 'SDF' . but not for other material types.
CALL Function 'L_IDOC_CREATE_WMTOID01'
Exporting
.....
....
Tables
ABC = ABC.
the issue is the table ABC is already having all the material types and thus creates the idocs for all the material types. But i need to create IDOC only for material types XYZ or SDF only. Please let me know if something is missing in my code.
Regards, Guru.
2016 Sep 13 2:29 PM
Hello Gururaj,
Create one temporary table gt_xyz_sdf and move the materials which have MTART as 'XYZ' and 'SDF' .
Finally pass the newly created table to Function Module.
Thanks,
Brijesh Gandhi
2016 Sep 13 3:10 PM
Hi Brijesh, tried creating a new new table with mtart values fetched. But finally i cant assign to function module as the structure in the table don't have mtart field. so there is type mismatch.
2016 Sep 13 3:28 PM
I have a FM with table parameter ABC of structure LTAP_VB.
on execution of the tcode, the table ABC is getting filled with all types of MTART in it.
my logic :
Read table ABC into wa_abc.
select * from mara where matnr = wa_abc-matnr and ( matnr = 'xyz' or matnr = 'SDF' ).
then calling the below FM
CALL L_IDOC_CREATE_WMTOID01
Tables
ABC = ABC.
For example if ABC is already having two materials with mtart as XYZ and OPU. But i want idoc to be created only for mtart XYZ and not for OPU as I'm fetching data from mara table .
Regards,
Guru
2016 Sep 14 6:46 AM
Hello Gururaj,
You can apply following logic, no need to create any new table :
loop at ABC into wa_abc.
select * from mara where matnr = wa_abc-matnr and (mtart = 'XYZ' or mtart = 'SDF').
If sy-subrc = 0.
CALL L_IDOC_CREATE_WMTOID01
Tables
T_LTAP = ABC.
endif.
endloop.
2016 Sep 14 7:53 AM
Please do not use Select statement inside Loop.
Use this instead.
IF abc[] is not initial.
SELECT matnr FROM mara INTO table lt_mara
FOR ALL ENTRIES IN abc
WHERE matnr = abc-matnr.
LOOP at abc INTO wa_abc.
****HAVE BINARY SORT on table lt_mara****
READ TABLE lt_mara WITH KEY matnr = wa_abc.
if SY-SUBRC IS INITIAL.
*****CALL YOUR FM.*****
ENDIF.
ENDLOOP.
2016 Sep 14 8:17 AM
Hi Gururaj,
Please define another internal table of type LTAP_VB (same as ABC) say 'ABC_NEW'. Then use the below algorithm:
If ABC[] is not initial.
select * from mara into it_mara for all entries in abc where matnr = abc-matnr and (mtart = 'XYZ' or mtart = 'SDF').
if sy-subrc = 0.
loop at abc into wa_abc.
read table it_matnr with key matnr = wa_abc-matnr. (sort and do binary search)
if sy-subrc = 0.
append wa_abc to abc_new.
endif.
endloop.
endif.
Endif.
if abc_new[] is not initial.
call the FM L_IDOC_CREATE_WMTOID01 with the internal table ABC_NEW.
endif.
Please let me know if this worked or not.
Regards,
Shayeree