2008 Mar 13 6:51 AM
I am trying to build a text file which is of the format: material, material description, material group, material group description, material type, material type description. There are 15,030 materials in mara. However there are much fewer material descriptions (in m_mat1s). So, when I run my program, I am not getting all the materials. I would like to include some text like "other" for the material description when there is no material description available in m_mat1s. This way all 15,030 materials will appear in the text file.
Additionally, I do not know if all material types and material groups have descriptions. If they do not, I would like to have in the text file a string like 'other' as the description.
Can you tell me how to modify the code to accomplish all of this?
BeginCode:
tables : mara, m_mat1s, t023t, t134t.
data matdim type string value 'c:\matdim.txt'.
data mdim type string.
data comma type string value ', '.
open dataset matdim for output in text mode encoding default.
select * from mara order by mtart matkl matnr.
select * from m_mat1s where matnr = mara-matnr.
select * from t023t where matkl = mara-matkl.
select * from t134t where mtart = mara-mtart and spras = 'E'.
concatenate mara-matnr comma m_mat1s-maktg comma mara-matkl comma t023t-wgbez comma mara-mtart comma t134t-mtbez into mdim.
transfer mdim to matdim.
endselect.
endselect.
endselect.
endselect.
close dataset matdim.
EndCode
I have only been programming in ABAP for about a week, so please explain everything simply.
Thanks,
Al Lal
I am trying to build a text file which is of the format: material, material description, material group, material group description, material type, material type description. There are 15,030 materials in mara. However there are much fewer material descriptions (in m_mat1s). So, when I run my program, I am not getting all the materials. I would like to include some text like "other" for the material description when there is no material description available in m_mat1s. This way all 15,030 materials will appear in the text file.
Additionally, I do not know if all material types and material groups have descriptions. If they do not, I would like to have in the text file a string like 'other' as the description.
Can you tell me how to modify the code to accomplish all of this?
BeginCode:
tables : mara, m_mat1s, t023t, t134t.
data matdim type string value 'c:\matdim.txt'.
data mdim type string.
data comma type string value ', '.
open dataset matdim for output in text mode encoding default.
select * from mara order by mtart matkl matnr.
select * from m_mat1s where matnr = mara-matnr.
select * from t023t where matkl = mara-matkl.
select * from t134t where mtart = mara-mtart and spras = 'E'.
concatenate mara-matnr comma m_mat1s-maktg comma mara-matkl comma t023t-wgbez comma mara-mtart comma t134t-mtbez into mdim.
transfer mdim to matdim.
endselect.
endselect.
endselect.
endselect.
close dataset matdim.
EndCode
I have only been programming in ABAP for about a week, so please explain everything simply.
Thanks,
Al Lal
2008 Mar 13 6:54 AM
Hi,
After getting matnr and materia desc into internal table, u can loop it and check if the field is initial. If yes, pass 'others' to the field. After this transfer the internal table.
Reward if helpful.
regards,
Ramya
2008 Mar 13 7:04 AM
Hi,
I have done for material description. Do the same for material type description also.
tables : mara, m_mat1s, t023t, t134t.
data matdim type string value 'c:\matdim.txt'.
data mdim type string.
data comma type string value ', '.
data l_desc type m_mat1s-maktg.
open dataset matdim for output in text mode encoding default.
select * from mara order by mtart matkl matnr.
select * from m_mat1s where matnr = mara-matnr.
select * from t023t where matkl = mara-matkl.
select * from t134t where mtart = mara-mtart and spras = 'E'.
if m_mat1s-maktg is initial.
l_desc = 'Others'.
else.
l_desc = m_mat1s-maktg.
endif.
concatenate mara-matnr comma l_desc comma mara-matkl comma t023t-wgbez comma mara-mtart comma t134t-mtbez into mdim.
transfer mdim to matdim.
endselect.
endselect.
endselect.
endselect.
close dataset matdim.
Regards,
Niyaz
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |