Hello gurus,
I have an issue with the below code. This is to get the division field from the table zgb_100 by doing look ups in different tables.
The code is logically but when I debug the code I see that the below highlighted part is not being picked up it is directly going
to the next step from IF ip_zgb_100-val1. Please let me know your valuable suggestion if my logic of extracting the division
is wrong. Thanks in advance
The division is extracted in this way
anln1 -> 10000002
anln2 = 0000
kostl : O613901 Using cost center, profit center P90309010 is from csks
Use profit center and get the field khinr from table cepc.
get the setname field from table setnode using the conditions and khinr
get the first 4 digits in setname field move them to division.
if the ip_zgb_100-val1 is initial get first 4 digits of khinr
and that is my division.
DATA: xprctr LIKEcsks-prctr.
DATA: kostl LIKE anlz-kostl
DATA: xkhinr LIKE cepc-khinr.
DATA: xsetname LIKE setnode-setname.
DATA: xsetn(4).
CLEAR: xkostl, xprctr, xsetname, xkhinr, xsetn, xprctr.
select kostl from anlz into xkostl
where bukrs = zbwfiaa_asset-bukrs and
anln1 = zbwfiaa_asset-anln1 and
anln2 = zbwfiaa_asset-anln2.
endselect.
SELECT SINGLE prctr FROM csks into xprctr
WHERE kostl = xkostl.
SELECT SINGLE khinr FROM cepc INTO xkhinr
WHERE prctr = zbwfiaa_asset-prctr.
SELECT SINGLE setname FROM setnode INTO xsetname
WHERE setclass = '0106'
AND subclass = lv_anla-bukrs
AND subsetname = xkhinr.
CLEAR ip_zgb_100.
MOVE xsetname+0(4) TO xsetn.
SELECT SINGLE val1 FROM zgb_100 INTO ip_zgb_100-val1
WHERE vtname = 'ASSET_DIVISION'
AND key1 = xsetn.
IF ip_zgb_100-val1 = 0.
CLEAR xsetn.
MOVE xkhinr+0(4) TO xsetn.
SELECT SINGLE val1 FROM zgb_100 INTO ip_zgb_100-val1
WHERE vtname = 'ASSET_DIVISION'
AND key1 = xsetn.
ENDIF.
IF sy-subrc = 0.
MOVE ip_zgb_100-val1 TO zbwfiaa_asset-zzdivision.
MODIFY i_t_data FROM zbwfiaa_asset INDEX l_tabix.
ENDIF.
Message was edited by: Matthew Billingham - added meaningful subject