Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Help needed urgently

Former Member
0 Likes
1,831

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>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,800

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

18 REPLIES 18
Read only

Former Member
0 Likes
1,800

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.

Read only

0 Likes
1,800

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.

Read only

0 Likes
1,800

HI Silviya,

did you try my code..

it shud work fine..

regards

satesh

Read only

0 Likes
1,800

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

Read only

0 Likes
1,800

Hi again,

1. debug and check your internal table

icdhdr.

2. Does it contain KS02 ?

regards,

amit m.

Read only

0 Likes
1,800

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.

Read only

0 Likes
1,800

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

Read only

0 Likes
1,800
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.
Read only

0 Likes
1,800

Hi all,

Thanks for all of your help. Its working fine.

Thanks,

Silviya t

Read only

Former Member
0 Likes
1,800

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.

Read only

Former Member
0 Likes
1,801

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

Read only

Former Member
0 Likes
1,800

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.

Read only

Former Member
0 Likes
1,800

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

Read only

Former Member
0 Likes
1,800

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

Read only

0 Likes
1,800

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

Read only

0 Likes
1,800

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.

Read only

0 Likes
1,800

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

Read only

Former Member
0 Likes
1,800

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.