2006 Mar 07 8:38 AM
Please help me how to code sequentially (order) . I have a loop icdhdr like this.
loop at icdhdr .
struct1-HDR = HDR.
struct1-OBJECTCLAS = icdhdr-OBJECTCLAS.
struct1-OBJECTID = icdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = icdhdr-CHANGENR.
struct1-USERNAME = icdhdr-USERNAME.
struct1-UDATE = icdhdr-UDATE.
struct1-UTIME = icdhdr-UTIME.
struct1-TCODE = icdhdr-TCODE.
struct1-PLANCHNGNR = icdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = icdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = icdhdr-WAS_PLANND.
struct1-CHANGE_IND = icdhdr-CHANGE_IND.
struct1-LANGU = icdhdr-LANGU.
struct1-VERSION = icdhdr-VERSION.
<b>struct1-BUKRS = it_skb1-bukrs.
struct1-cost = w_cost.</b>
endloop.
1. we have to pass value for <b>struct1-BUKRS</b> as a additional field in loop icdhdr If the following condition satisfies .
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
w_KTOPL = icdhdr-objectid(4).
w_saknr = icdhdr-objectid+4(10).
select bukrs from t001 into table it_t001
where KTOPL eq w_KTOPL.
loop at it_t001.
select bukrs from skb1 into it_skb1
where bukrs eq it_t001-bukrs
and saknr eq w_saknr.
check sy-subrc eq 0.
append it_skb1.
endselect.
endloop.
2. we have to pass value for <b>struct1-co</b>st as a additional field in loop icdhdr If the following condition satisfies .
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
Endif.
<b>3.Note : I am passing Tcode value using ranges ie multiple tcodes</b>.
<b> i should work if i give KS02 & FS00 at a time</b>
2006 Mar 07 8:50 AM
hi SILVIYA
TRY THIS
loop at icdhdr .
struct1-HDR = HDR.
struct1-OBJECTCLAS = icdhdr-OBJECTCLAS.
struct1-OBJECTID = icdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = icdhdr-CHANGENR.
struct1-USERNAME = icdhdr-USERNAME.
struct1-UDATE = icdhdr-UDATE.
struct1-UTIME = icdhdr-UTIME.
struct1-TCODE = icdhdr-TCODE.
struct1-PLANCHNGNR = icdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = icdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = icdhdr-WAS_PLANND.
struct1-CHANGE_IND = icdhdr-CHANGE_IND.
struct1-LANGU = icdhdr-LANGU.
struct1-VERSION = icdhdr-VERSION.
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
w_KTOPL = icdhdr-objectid(4).
w_saknr = icdhdr-objectid+4(10).
select bukrs from t001 into table it_t001
where KTOPL eq w_KTOPL.
loop at it_t001.
select bukrs from skb1 into <b>it_skb1-BURKS</b>
where bukrs eq it_t001-bukrs
and saknr eq w_saknr.
check sy-subrc eq 0.
append it_skb1.
endselect.
endloop.
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
Endif.
struct1-BUKRS = <b>it_skb1-bukrs.</b> ---><b> which bukrs because it_skb1 can contain multiple bukrs.</b>
struct1-cost = w_cost.
<b>APPEND STRUCT1.</b>
endloop.
REGARDS
KISHORE
Message was edited by: Harikishore Sreenivasulu
hi SILVIYA
TRY THIS
loop at icdhdr .
struct1-HDR = HDR.
struct1-OBJECTCLAS = icdhdr-OBJECTCLAS.
struct1-OBJECTID = icdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = icdhdr-CHANGENR.
struct1-USERNAME = icdhdr-USERNAME.
struct1-UDATE = icdhdr-UDATE.
struct1-UTIME = icdhdr-UTIME.
struct1-TCODE = icdhdr-TCODE.
struct1-PLANCHNGNR = icdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = icdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = icdhdr-WAS_PLANND.
struct1-CHANGE_IND = icdhdr-CHANGE_IND.
struct1-LANGU = icdhdr-LANGU.
struct1-VERSION = icdhdr-VERSION.
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
w_KTOPL = icdhdr-objectid(4).
w_saknr = icdhdr-objectid+4(10).
select bukrs from t001 into table it_t001
where KTOPL eq w_KTOPL.
loop at it_t001.
select bukrs from skb1 into <b>it_skb1-BURKS</b>
where bukrs eq it_t001-bukrs
and saknr eq w_saknr.
check sy-subrc eq 0.
append it_skb1.
endselect.
endloop.
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
Endif.
struct1-BUKRS = <b>it_skb1-bukrs.</b> ---><b> which bukrs because it_skb1 can contain multiple bukrs.</b>
struct1-cost = w_cost.
<b>APPEND STRUCT1.</b>
endloop.
REGARDS
KISHORE
Message was edited by: Harikishore Sreenivasulu
2006 Mar 07 8:47 AM
Hi Silviya,
There is something to clarify...
1. YOu have to update struct1 based on BUKRS.
But the select statement returns many values of BUKRS.
Do you want to append all these entries.
2.w_cost = icdhdr-objectid(4).
Do you want to update struct1-cost based on w_cost?
loop at icdhdr .
struct1-HDR = HDR.
struct1-OBJECTCLAS = icdhdr-OBJECTCLAS.
struct1-OBJECTID = icdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = icdhdr-CHANGENR.
struct1-USERNAME = icdhdr-USERNAME.
struct1-UDATE = icdhdr-UDATE.
struct1-UTIME = icdhdr-UTIME.
struct1-TCODE = icdhdr-TCODE.
struct1-PLANCHNGNR = icdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = icdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = icdhdr-WAS_PLANND.
struct1-CHANGE_IND = icdhdr-CHANGE_IND.
struct1-LANGU = icdhdr-LANGU.
struct1-VERSION = icdhdr-VERSION.
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
struct1-cost = w_cost.
Endif.
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
w_KTOPL = icdhdr-objectid(4).
w_saknr = icdhdr-objectid+4(10).
select bukrs from t001 into table it_t001
where KTOPL eq w_KTOPL.
loop at it_t001.
select bukrs from skb1 into it_skb1
where bukrs eq it_t001-bukrs
and saknr eq w_saknr.
check sy-subrc eq 0.
append it_skb1.
endselect.
endloop.
<b>LOOP AT it_skb1.
struct1-bukrs = it_skb1-bukrs.
APPEND struct1.
ENDLOOP.</b>
endloop.Regards,
Wenceslaus.
2006 Mar 07 9:21 AM
Hi Wenceslaus ,
I have coded as you mentioned. Its working for only tcode FS00. & not for KS02.
Its not showing output for KS02 while I am giving multiple tcodes (FS00,KS02).
I want output for both FS00 & ks02 tcodes,
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
struct1-cost = w_cost.
Endif.
I also need to display struct1 with field struct1-cost = w_cost if the above condition satisfies.
2006 Mar 07 9:23 AM
HI Silviya,
did you try my code..
it shud work fine..
regards
satesh
2006 Mar 07 9:28 AM
HI silviya
if your using Ranges then
if you want output for both FS00 & ks02 tcodes,
if icdhdr-tcode <b>IN <RANGE ></b>
w_cost = icdhdr-objectid(4).
struct1-cost = w_cost.
Endif.
regards
kishore
2006 Mar 07 9:28 AM
Hi again,
1. debug and check your internal table
icdhdr.
2. Does it contain KS02 ?
regards,
amit m.
2006 Mar 07 10:54 AM
hi Satesh,
Everything is working fine. But problem : it_skb1 last record is coming two times.i think that we are using Append statement two times. i am not getting exact output if i remove one append statement.what i have to do?
*check the condition and read it_skb1 in the same order
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
loop at it_skb1.
struct1-BUKRS = it_skb1-bukrs.
struct1-cost = space.
append struct1.
endloop.
endif.
*check the condition
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
struct1-cost = w_cost.
else.
struct1-cost = space.
endif.
append struct1.
endloop.
2006 Mar 07 11:01 AM
hi Silviya,
if you think the last record is coming two times..
just delete that record alone..
use
delete adjacent duplicates from it_skb1 comparing all fields.or
describe table it_skb1 lines lin.
delete it_skb1 index lin.
this deletes the last record alone
regards
satesh
2006 Mar 07 11:13 AM
loop at icdhdr .
CLEAR struct1.
struct1-HDR = HDR.
struct1-OBJECTCLAS = icdhdr-OBJECTCLAS.
struct1-OBJECTID = icdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = icdhdr-CHANGENR.
struct1-USERNAME = icdhdr-USERNAME.
struct1-UDATE = icdhdr-UDATE.
struct1-UTIME = icdhdr-UTIME.
struct1-TCODE = icdhdr-TCODE.
struct1-PLANCHNGNR = icdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = icdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = icdhdr-WAS_PLANND.
struct1-CHANGE_IND = icdhdr-CHANGE_IND.
struct1-LANGU = icdhdr-LANGU.
struct1-VERSION = icdhdr-VERSION.
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
w_KTOPL = icdhdr-objectid(4).
w_saknr = icdhdr-objectid+4(10).
select bukrs from t001 into table it_t001
where KTOPL eq w_KTOPL.
loop at it_t001.
select bukrs from skb1 into it_skb1
where bukrs eq it_t001-bukrs
and saknr eq w_saknr.
check sy-subrc eq 0.
append it_skb1.
endselect.
endloop.
LOOP AT it_skb1.
struct1-bukrs = it_skb1-bukrs.
APPEND struct1.
ENDLOOP.
ENDIF.
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
struct1-cost = w_cost.
APPEND struct1
Endif.
endloop.
2006 Mar 07 11:18 AM
Hi all,
Thanks for all of your help. Its working fine.
Thanks,
Silviya t
2006 Mar 07 8:48 AM
Hi silviya,
1. f icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
We can also use like this :
if icdhdr-tcode in myrange.
regards,
amit m.
2006 Mar 07 8:50 AM
hi SILVIYA
TRY THIS
loop at icdhdr .
struct1-HDR = HDR.
struct1-OBJECTCLAS = icdhdr-OBJECTCLAS.
struct1-OBJECTID = icdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = icdhdr-CHANGENR.
struct1-USERNAME = icdhdr-USERNAME.
struct1-UDATE = icdhdr-UDATE.
struct1-UTIME = icdhdr-UTIME.
struct1-TCODE = icdhdr-TCODE.
struct1-PLANCHNGNR = icdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = icdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = icdhdr-WAS_PLANND.
struct1-CHANGE_IND = icdhdr-CHANGE_IND.
struct1-LANGU = icdhdr-LANGU.
struct1-VERSION = icdhdr-VERSION.
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
w_KTOPL = icdhdr-objectid(4).
w_saknr = icdhdr-objectid+4(10).
select bukrs from t001 into table it_t001
where KTOPL eq w_KTOPL.
loop at it_t001.
select bukrs from skb1 into <b>it_skb1-BURKS</b>
where bukrs eq it_t001-bukrs
and saknr eq w_saknr.
check sy-subrc eq 0.
append it_skb1.
endselect.
endloop.
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
Endif.
struct1-BUKRS = <b>it_skb1-bukrs.</b> ---><b> which bukrs because it_skb1 can contain multiple bukrs.</b>
struct1-cost = w_cost.
<b>APPEND STRUCT1.</b>
endloop.
REGARDS
KISHORE
Message was edited by: Harikishore Sreenivasulu
2006 Mar 07 8:51 AM
loop at icdhdr.
all ur fields as indicated by u
.....
Case tcode.
when 'FS00' or 'FSPO'.
all ur logic as coded by u for struct1-bukrs.
when 'KS01' or 'KS02'.
all ur logic as coded by u for struct1-cost
endcase.
2006 Mar 07 8:52 AM
Hi
Where's the problem?
You're using a range to uploading the hits from CDHDR table, and I think it's ok.
After you should check the single value of tcode to choose the action you have to do, so your control seem ok too.
Max
2006 Mar 07 8:52 AM
hi Silviya,
this one shud work..
*here populate the it_skb1 initially..
loop at icdhdr where tcode = 'FS00' or tcode = 'FSP0' .
w_KTOPL = icdhdr-objectid(4).
w_saknr = icdhdr-objectid+4(10).
select bukrs from t001 into table it_t001
where KTOPL eq w_KTOPL.
loop at it_t001.
select bukrs from skb1 into it_skb1
where bukrs eq it_t001-bukrs
and saknr eq w_saknr.
check sy-subrc eq 0.
append it_skb1.
endselect.
endloop.
endloop.
*a small counter i for the index of it_skb1.
data : i type i.
*now the same logic..
loop at icdhdr .
struct1-HDR = HDR.
struct1-OBJECTCLAS = icdhdr-OBJECTCLAS.
struct1-OBJECTID = icdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = icdhdr-CHANGENR.
struct1-USERNAME = icdhdr-USERNAME.
struct1-UDATE = icdhdr-UDATE.
struct1-UTIME = icdhdr-UTIME.
struct1-TCODE = icdhdr-TCODE.
struct1-PLANCHNGNR = icdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = icdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = icdhdr-WAS_PLANND.
struct1-CHANGE_IND = icdhdr-CHANGE_IND.
struct1-LANGU = icdhdr-LANGU.
struct1-VERSION = icdhdr-VERSION.
*check the condition and read it_skb1 in the same order
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
i = i + 1.
read table it_skb1 index i.
struct1-BUKRS = it_skb1-bukrs.
endif.
*check the condition
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
struct1-cost = w_cost.
endif.
endloop.regards
satesh
2006 Mar 07 9:47 AM
hi Satesh,
Its working fine for both tcodes.it_skb1 contains multiple values.
1.But the problem is output showing only first record of it_skb1.Its not showing all values in It_skb1.
2.I have to add cost value for struct1-cost if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
.
Here i am getting struct1-cost value for all tcodes (for FS00 & KS02).
help me.
Thanks
2006 Mar 07 9:54 AM
Hi Silviya,
We are modifying your code based on your previous codes and conditions that you have applied in.
It would be helpful if you can specify your complete requirement.
Regards,
Wenceslaus.
2006 Mar 07 9:58 AM
HI Silviya,
> But the problem is output showing only first record of it_skb1.Its not showing all values in It_skb1.
i just restricted it to one value using index at read ..
you can use
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
loop at it_skb1.
struct1-BUKRS = it_skb1-bukrs.
append struct1.
endloop.
endif.> have to add cost value for struct1-cost if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
but we have clearly mentionesd the condition as
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
struct1-cost = w_cost.
endif.regards
satesh
2006 Mar 07 9:31 AM
Hi Silviya,
<b>Can you please tell me what is the value of bukrs
to be updated when the tcode is KS02.</b>
loop at icdhdr .
struct1-HDR = HDR.
struct1-OBJECTCLAS = icdhdr-OBJECTCLAS.
struct1-OBJECTID = icdhdr-OBJECTID.
struct1-KEYVALUE = w_kvalue.
struct1-CHANGENR = icdhdr-CHANGENR.
struct1-USERNAME = icdhdr-USERNAME.
struct1-UDATE = icdhdr-UDATE.
struct1-UTIME = icdhdr-UTIME.
struct1-TCODE = icdhdr-TCODE.
struct1-PLANCHNGNR = icdhdr-PLANCHNGNR.
struct1-ACT_CHNGNO = icdhdr-ACT_CHNGNO.
struct1-WAS_PLANND = icdhdr-WAS_PLANND.
struct1-CHANGE_IND = icdhdr-CHANGE_IND.
struct1-LANGU = icdhdr-LANGU.
struct1-VERSION = icdhdr-VERSION.
if icdhdr-tcode = 'KS01' or icdhdr-tcode = 'KS02'.
w_cost = icdhdr-objectid(4).
struct1-cost = w_cost.
Endif.
if icdhdr-tcode = 'FS00' Or icdhdr-tcode = 'FSP0' .
w_KTOPL = icdhdr-objectid(4).
w_saknr = icdhdr-objectid+4(10).
select bukrs from t001 into table it_t001
where KTOPL eq w_KTOPL.
loop at it_t001.
select bukrs from skb1 into it_skb1
where bukrs eq it_t001-bukrs
and saknr eq w_saknr.
check sy-subrc eq 0.
append it_skb1.
endselect.
endloop.
LOOP AT it_skb1.
struct1-bukrs = it_skb1-bukrs.
APPEND struct1.
ENDLOOP.
ELSE.
.....................
"Insert your logic here.
ENDIF.
endloop.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |