‎2016 Feb 20 1:11 AM
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 LIKE csks-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
‎2016 Feb 20 5:13 AM
It's probably activation.
Activate the code (again) and put a breakpoint on that highlighted code. Execute.
cheers
Paul
‎2016 Feb 20 5:13 AM
It's probably activation.
Activate the code (again) and put a breakpoint on that highlighted code. Execute.
cheers
Paul
‎2016 Feb 20 5:19 AM
Hi Paul,
Thank you for your response I have activated it multiple times and transported it into quality system. When I put the break point at the activated part it does not run and execute at that point.
‎2016 Feb 20 10:39 PM
Hi,
Are you saying that when you debug it steps right over the statement
MOVE xsetname+0(4) TO xsetn.
without executing it?
Sorry, I can't see any explanation for that, other than the code you are viewing in the debugger is not the same that is executing. Activation should fix that!
(Checking sy-subrc should certainly also be done, but it won't affect this behaviour)
cheers
Paul
‎2016 Feb 21 12:10 PM
Hi,
in the statement IF ip_zgb_100-val1 = 0. , if the field is of character type then give like
IF ip_zgb_100-val1 = '0' .
‎2016 Feb 21 2:11 PM
Hi,
- use pretty printer finction in editor just to see the structure.
- use extende program check, code inspector, to see what's wrong
- zbwfiaa_asset-prctr (used in where clausse) is not populated thus initial
This will give you much insight
Regards Clemens
‎2016 Feb 20 9:42 PM
You are not checking sy-subrc after each SELECT statement. You can put a break-point before the first SELECT and see the value of sy-subrc after each call. In any case, you should add some logic to handle non-zero return codes.
Rob
‎2016 Feb 22 2:32 AM
Thank you Paul, Rob, Clemens, Renjith the issue was that the company code was not passing through the code
WHERE setclass = '0106'
AND subclass = lv_anla-bukrs
AND subsetname = xkhinr.
The mistake I did here is I was supposed to give the the extract structure zbwfiaa_asset-bukrs( where the company code passes in). As the company code was not passing through bukrs the ip_zgb_100-val1 = 0
condition was not executing.
Thank you all for your help in this.
‎2016 Feb 22 9:47 PM
I'm very glad to hear it's resolved, but your explanation does not actually explain how those two statements were skipped during debugging.
The SELECT SINGLE statement failed to find anything because of a missing bukrs? That won't stop it executing the next line.
Also, once your issue is resolved, you should mark one answer as 'correct' (even if it's your own) to set the discussion to 'Answered'.
cheers
Paul
‎2016 Feb 22 8:00 AM
Moderator message: please use a meaningful subject in future. "Issue within the program" is not meaningful. I've edited it for you this time, but you risk having your post rejected.