02-22-2006 4:59 PM
Hi Experts,
here are material no's in one internal table.
for each material number i have to select the BOM component whose BOM Alternative Text = 'DEV'.
i'm selecting the BOM component like this. But it is not showing up results when executing..
Please tell me what is the problme with this?
THE CODE IS LIKE THIS:
<b>data: begin of material_data occurs 0,
matnr like mara-matnr,
...................
...................
end of material_data.
data: str1(2) type c value 'O',
str2(2) type c value 'OP',
str3(2) type c value 'M',
str4(2) type c value 'MP'.
<u>i have changed the itab like this....</u>
data: begin of i_bom occurs 0,
stlal like stko-stlal,
stktx like stko-stktx,
stlnr like stko-stlnr,
end of i_bom.
data: begin of i_outsert occurs 0,
idnrk like stpo-idnrk,
end of i_outsert.
data: begin of i_awp occurs 0,
matnr like mara-matnr,
rate like konp-kbetr,
end of i_awp.
data: v_lines type i.
constants: c_unrestr(12) type c value 'DEV'.
-
-
-
perform get_outsert.
-
-
form get_outsert.
clear material_data.
refresh material_data.
select matnr from mara into corresponding fields of table
material_data where mtart = 'FERT'.
append material_data.
select single * from mast where matnr = material_data-matnr.
if sy-subrc = 0.
clear i_bom.
refresh i_bom.
select stlal stktx from stko
into i_bom where stlnr = mast-stlnr.
append i_bom.
clear i_bom.
endselect.
endif.
loop at i_bom.
translate i_bom-stktx to upper case.
modify i_bom transporting stktx.
endloop.
clear i_bom.
delete i_bom where stktx(12) <> c_unrestr.
if v_lines = 1.
read table i_bom.
if sy-subrc = 0.
select idnrk from stpo into i_outsert-idnrk
where stlnr = stko-stlnr.
append i_outsert.
endselect.
endif.
if ( i_outsert-idnrk cs str1 ) or ( i_outsert-idnrk cs str2 ).
move i_outsert-idnrk to material_data-component.
elseif ( i_outsert-idnrk cs str3 ) or
( i_outsert-idnrk cs str4 ).
move i_outsert-idnrk to material_data-mguide.
endif.
modify material_data.
endif.
endform. "get_outsert</b>
thnx.
Message was edited by: venu gopal
Message was edited by: venu gopal
02-22-2006 5:21 PM
First change this.
select matnr from mara into corresponding fields of table
material_data where mtart = 'FERT'.
<b>if sy-subrc = 0.</b>
loop at material_data
<b>select single * from mast
where matnr = material_data-matnr .</b>
exit.
<b>endloop.</b>
Also change this.
Add this field in Internal table i_bom (stlnr)
read table i_bom.
if sy-subrc = 0.
select idnrk from stpo into i_outsert-idnrk
where stlnr = <b>i_bom-stlnr.</b>
append i_outsert.
endselect.
endif.
02-22-2006 5:05 PM
u have to use loop endloop ,
select matnr from mara into corresponding fields of table
material_data where mtart = 'FERT'.
append material_data.
<b>loop at material_dat.</b>
select single * from mast where matnr = material_data-matnr.
<b>endloop</b>
if sy-subrc = 0.
clear i_bom.
refresh i_bom.
select stlal stktx from stko
into i_bom where stlnr = mast-stlnr.
append i_bom.
clear i_bom.
endselect.
endif.
02-22-2006 5:06 PM
delete i_bom where stktx(12) <> c_unrestr.
if v_lines = 1.
read table i_bom.
if sy-subrc = 0.
select idnrk from stpo into i_outsert-idnrk
******
where stlnr = stko-stlnr.
****here stko-stlnr *****change it to i_bom-stlnr
put break-points and debug the code whether the values were populating properly or not.
append i_outsert.
endselect.
endif
Message was edited by: Hasmath
02-22-2006 5:10 PM
hasmath,
but there is no "i_bom-stlnr" declared in that itab.
it gives error, right?
02-22-2006 5:16 PM
Hi Venu,
In this select statement how will u be getting matnr from material_data , unless u loop at table or use FOR ALL ENTRIES , u will not get that value
select single * from mast where matnr = material_data-matnr.
02-22-2006 5:21 PM
02-22-2006 5:21 PM
HI
change this
data: begin of material_data occurs 0,
matnr like mara-matnr,
...................
...................
end of material_data.
data: str1(2) type c value 'O',
str2(2) type c value 'OP',
str3(2) type c value 'M',
str4(2) type c value 'MP'.
data: begin of i_bom occurs 0,
stlal like stko-stlal,
stktx like stko-stktx,
end of i_bom.
data: begin of i_outsert occurs 0,
idnrk like stpo-idnrk,
end of i_outsert.
data: begin of i_awp occurs 0,
matnr like mara-matnr,
rate like konp-kbetr,
end of i_awp.
data: v_lines type i.
constants: c_unrestr(12) type c value 'DEV'.
-
-
-
perform get_outsert.
-
-
form get_outsert.
clear material_data.
refresh material_data.
select matnr from mara into corresponding fields of table
material_data where mtart = 'FERT'.
<b>loop at material_data.</b>
select single * from mast where matnr = material_data-matnr.
if sy-subrc = 0.
clear i_bom.
refresh i_bom.
select stlal stktx from stko
into table i_bom where stlnr = mast-stlnr.
endif.
loop at i_bom.
translate i_bom-stktx to upper case.
modify i_bom transporting stktx.
endloop.
clear i_bom.
delete i_bom where stktx(12) <> c_unrestr.
if v_lines = 1.
read table i_bom with key stktx eq c_unrestr.
if sy-subrc = 0.
select idnrk from stpo into table i_outsert
where stlnr = <b><table>-stlnr.</b>
endif.
if ( i_outsert-idnrk cs str1 ) or ( i_outsert-idnrk cs str2 ).
move i_outsert-idnrk to material_data-component.
elseif ( i_outsert-idnrk cs str3 ) or
( i_outsert-idnrk cs str4 ).
move i_outsert-idnrk to material_data-mguide.
endif.
modify material_data.
endif.
<b>endloop.</b>
endform. "get_outsert
regards
kishore
02-22-2006 5:21 PM
First change this.
select matnr from mara into corresponding fields of table
material_data where mtart = 'FERT'.
<b>if sy-subrc = 0.</b>
loop at material_data
<b>select single * from mast
where matnr = material_data-matnr .</b>
exit.
<b>endloop.</b>
Also change this.
Add this field in Internal table i_bom (stlnr)
read table i_bom.
if sy-subrc = 0.
select idnrk from stpo into i_outsert-idnrk
where stlnr = <b>i_bom-stlnr.</b>
append i_outsert.
endselect.
endif.
02-22-2006 5:48 PM
<b>if sy-subrc = 0.
select idnrk from stpo into i_outsert-idnrk
where stlnr = i_bom-stlnr.</b>
but there is no values for "i_bom-stlnr". we are not selecting data for that field.
plz tell me what can be done to correct that?
thnx
02-22-2006 5:54 PM
Once you delete data from I_BOM based upon the text condition, check if table is initial.
Also you need to select STLNR from MAST to I_BOM internal table. This will be used for further processing.
Check in debug mode if you are getting values after each step.
If still you have problems, post your code. I shall have a look and get back to you.
Message was edited by: Ashish Gundawar
02-22-2006 5:55 PM
Hi Venu,
I remember reading somewhere that you shouldn't be reading BOM data directly from a Table.. but instead retrieve the data via a function call..like 'CO_MP_BOM_READ'.
Regards,
Suresh Datti
02-22-2006 5:55 PM
02-22-2006 6:02 PM
ashish,
please tell me where should i have to do this select for <b>stlnr</b>.
in the code, i'm filling the i_bom with data like this.
<b> clear i_bom.
refresh i_bom.
select stlal stktx from stko
into i_bom where stlnr = mast-stlnr.
append i_bom.
clear i_bom.
endselect</b>.
should i have to select the stlnr before this select statement.
plz tell me.
thnx
02-22-2006 6:04 PM
Check this out
data: begin of i_bom occurs 0,
stlnr like stko-stlnr,
stlal like stko-stlal,
stktx like stko-stktx,
end of i_bom.
clear i_bom.
refresh i_bom.
select STLNR stlal stktx from stko
into i_bom where stlnr = mast-stlnr.
append i_bom.
clear i_bom.
endselect.
02-22-2006 6:06 PM
just a small correction ..
use the following SELECT for better performance..
select STLNR stlal stktx from stko
into table i_bom where stlnr = mast-stlnr.
Regards,
Suresh Datti
02-22-2006 6:39 PM
when debugging the code, i could see the values for internal table <b>i_bom</b>.
but when checking that with,
<b>if v_lines = 1.</b>
there it is showing v_lines = 0.
i dont understand why it is showing up like that?
could you please let me know.
thnx.
02-22-2006 6:43 PM
Hi Venu,
Where are you populating V_lines .
After delete write the following :
Describe table I_BOM lines V_lines.
Then V_lins shows no.of lines in I_BOM.
Regards,
Lanka
02-22-2006 6:46 PM
insert the following statement before if v_lines = 1.
v_lines = lines( i_bom ).
Regards,
Suresh Datti
02-22-2006 7:14 PM
friends it is working fine..
but while debugging it is going to short dump after the statement,
<b> if ( i_outsert-idnrk cs str1 ) or ( i_outsert-idnrk cs str2 ).
write i_outsert-idnrk to material_data-component.
elseif ( i_outsert-idnrk cs str3 ) or
( i_outsert-idnrk cs str4 ).
write i_outsert-idnrk to material_data-mguide.
endif.
modify material_data.</b>
the values are getting transfered from <b>i_outsert</b> to <b>material_data</b>,
but after the statement,
<b>modify material_data.</b>.
it is going to short dump saying that...
"TABLE ILLEGAL STATEMENT".
could you please tell me what could be the reason for this?
the MATERIAL_DATA itab is like this:
<b>data: begin of material_Data occurs 0,
matnr like mara-matnr,
component like stpo-idnrk,
mguide like stpo-idnrk,
-
-
end of material_data.</b>
thnx.
02-22-2006 7:17 PM
Is MODIFY MATERIAL_DATA is in a LOOP for table MATERIAL_DATA??
In that case provide INDEX.
Else if it is not in any loop provide condition and use 'TRANSPORTING' clause.
Like
MODIFY MATERIAL_DATA WHERE FIELD = xxx TRANSPORTING MGUIDE.
02-22-2006 7:17 PM
02-22-2006 7:17 PM
Hi venugopal,
Write the modify statement this way.
MODIFY MATERIAL_DATA TRANSPORTING COMPONENT MGUIDE.
02-22-2006 7:19 PM
Hi Venu ,
Use Trsnporting along with modify:
MODIFY MATERIAL_DATA TRANSPORTING IDNRK.
Lanka
02-22-2006 7:24 PM
ashish,
how to write that using INDEX ?
I'm still getting the error.
plz let me know.
thnx
02-22-2006 7:26 PM
if it is in loop
data:l_index like sy-tabix.
loop at material_data.
l_index = sy-tabix.
modify material_data index l_index transporting idnrk.
endloop.
02-22-2006 7:26 PM
but there is no component "IDNRK" in MATERIAL_DATA.
So i will get errors, right?
02-22-2006 7:28 PM
Hi Venu,
If there is no read statements in the loop & endloop,you can use
MODIFY MATERIAL_DATA INDEX SY-TABIX.
If there are any read statements ,then you have to move the sy-tabix value into a variable say v_index,just after the LOOP statement & then write
MODIFY MATERIAL_DATA INDEX V_INDEX.
declare V_INDEX AS..
DATA:V_INDEX LIKE SY-TABIX.
02-22-2006 7:29 PM
02-22-2006 7:29 PM
sorry it is mguide
data:l_index like sy-tabix.
loop at material_data.
l_index = sy-tabix.
modify material_data index l_index transporting component mguide.
endloop.
Message was edited by: Sekhar
02-22-2006 7:30 PM
My understanding is you want to modify records from MATERIAL_DATA based upon condition.
Try this out -
MODIFY MATERIAL_DATA where (use condition) transporting MGUIDE.
If every time you will be inserting data into MATERIAL_DATA, you can use
APPEND MATERIAL_DATA.
02-22-2006 7:38 PM
try using modi fy 2 times , one in if and the other in elseif
if ( i_outsert-idnrk cs str1 ) or ( i_outsert-idnrk cs str2 ).
move i_outsert-idnrk to material_data-component.
<b>modify material_data index l_index transporting component.</b>
elseif ( i_outsert-idnrk cs str3 ) or
( i_outsert-idnrk cs str4 ).
move i_outsert-idnrk to material_data-mguide.
<b>modify material_data index l_index transporting mguide</b>
endif.
02-22-2006 6:42 PM
u r populating the value of v_lines anywhere in the code
if u want no of records in i_BOM , then u have to write
DESCRIBE TABLE I_BOM LINES V_LINES
Message was edited by: Sekhar
02-22-2006 10:29 PM