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

not working....

Former Member
0 Likes
1,349

Hi all,

for the below code i am getting o/p as nothing(null)...

DATA : v_knttp(25) TYPE c.

SHIFT v_knttp LEFT DELETING LEADING space.

CASE lt_ekpo-knttp.

WHEN 'K'.

MOVE lt_ekkn-kostl TO v_knttp.

WHEN 'P'.

MOVE lt_ekkn-ps_psp_pnr TO v_knttp.

WHEN 'O'.

MOVE lt_ekkn-aufnr TO v_knttp.

WHEN OTHERS.

MOVE lt_ekpo-knttp TO v_knttp.

ENDCASE.

write: v_knttp.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,321

Hi Vj,

Try this way out it works only if there exists data.

DATA : v_knttp(25) TYPE c.

SHIFT v_knttp LEFT DELETING LEADING space.

<b>loop at lt_ekpo.</b>

CASE lt_ekpo-knttp.

WHEN 'K'.

v_knttp = lt_ekkn-kostl.

WHEN 'P'.

v_knttp = lt_ekkn-ps_psp_pnr.

WHEN 'O'.

v_knttp = lt_ekkn-aufnr.

WHEN OTHERS.

v_knttp = lt_ekpo-knttp.

ENDCASE.

<b>endloop.</b>

write: v_knttp.

Regards,

Santosh

12 REPLIES 12
Read only

Former Member
0 Likes
1,322

Hi Vj,

Try this way out it works only if there exists data.

DATA : v_knttp(25) TYPE c.

SHIFT v_knttp LEFT DELETING LEADING space.

<b>loop at lt_ekpo.</b>

CASE lt_ekpo-knttp.

WHEN 'K'.

v_knttp = lt_ekkn-kostl.

WHEN 'P'.

v_knttp = lt_ekkn-ps_psp_pnr.

WHEN 'O'.

v_knttp = lt_ekkn-aufnr.

WHEN OTHERS.

v_knttp = lt_ekpo-knttp.

ENDCASE.

<b>endloop.</b>

write: v_knttp.

Regards,

Santosh

Read only

abdul_hakim
Active Contributor
0 Likes
1,321

Hi u need to loop through it_ekpo if it is an internal table. also it is meaningless to SHIFT v_knttp since it doesnt contain any value.Check the below code..

DATA : v_knttp(25) TYPE c.

LOOP AT it_ekpo.

CASE lt_ekpo-knttp.

WHEN 'K'.

MOVE lt_ekkn-kostl TO v_knttp.

WHEN 'P'.

MOVE lt_ekkn-ps_psp_pnr TO v_knttp.

WHEN 'O'.

MOVE lt_ekkn-aufnr TO v_knttp.

WHEN OTHERS.

MOVE lt_ekpo-knttp TO v_knttp.

ENDCASE.

write: v_knttp.

clear v_knttp.

ENDLOOP.

Cheers,

Abdul Hakim

Read only

Former Member
0 Likes
1,321

Try this

DATA : v_knttp(25) TYPE c.

SHIFT v_knttp LEFT DELETING LEADING space.

CASE lt_ekpo-knttp.

WHEN 'K'.

<b>write</b> lt_ekkn-kostl TO v_knttp.

WHEN 'P'.

<b>write</b> lt_ekkn-ps_psp_pnr TO v_knttp.

WHEN 'O'.

<b>write</b> lt_ekkn-aufnr TO v_knttp.

WHEN OTHERS.

<b>write</b> lt_ekpo-knttp TO v_knttp.

ENDCASE.

write: v_knttp.

Read only

0 Likes
1,321

hello experts....

i declared internal table....but see the code i think...there is some more thing to be attached????

Read only

0 Likes
1,321

hi

you are not looping thru your internal table so plz loop thru it as i have mentioned above and update here with the result..

Cheers,

Abdul Hakim

Read only

0 Likes
1,321

still it is not showing...please help me ...give other suggestions....

Thanks in advance

Read only

0 Likes
1,321

Can you please post the complete code.

Regards,

Rich Heilman

Read only

0 Likes
1,321

can you plz give ur complete code here?

Cheers,

Abdul Hakim

Read only

Former Member
0 Likes
1,321

You are checking values of 'K', 'O', etc.

Debug your program and see if there is such values for lt_ekpo-knttp.

Otherwise if it is your requirement to check only the first letter, declare another field with a single character.

DATA : v_knttp(25) TYPE c,

v_sing(1).

SHIFT v_knttp LEFT DELETING LEADING space.

move lt_ekpo-knttp to v_sing.

CASE v_sing.

WHEN 'K'.

MOVE lt_ekkn-kostl TO v_knttp.

WHEN 'P'.

MOVE lt_ekkn-ps_psp_pnr TO v_knttp.

WHEN 'O'.

MOVE lt_ekkn-aufnr TO v_knttp.

WHEN OTHERS.

MOVE lt_ekpo-knttp TO v_knttp.

ENDCASE.

write: v_knttp.

Read only

Former Member
0 Likes
1,321

After declaring the internal table, did you fill it??

Regards,

Amiya Shrivastava

Read only

0 Likes
1,321

DATA : v_knttp(25) TYPE c.

LOOP AT it_ekpo.

CASE lt_ekpo-knttp.

WHEN 'K'.

MOVE lt_ekkn-kostl TO v_knttp.

WHEN 'P'.

MOVE lt_ekkn-ps_psp_pnr TO v_knttp.

WHEN 'O'.

MOVE lt_ekkn-aufnr TO v_knttp.

WHEN OTHERS.

MOVE lt_ekpo-knttp TO v_knttp.

ENDCASE.

write: v_knttp.

clear v_knttp.

ENDLOOP.

Read only

Former Member
0 Likes
1,321

Hi VJ,

As per your code :

DATA : v_knttp(25) TYPE c.

*Is v_knttp already populated.Chk in debug. If yes, then *in case statement,why are you again moving value into *this field.

SHIFT <b>v_knttp</b> LEFT DELETING LEADING space.

*lt_ekkn-knttp should be coming from internal table *loop. Check if there is an loop before it.

CASE <b>lt_ekpo-knttp</b>.

WHEN 'K'.

MOVE lt_ekkn-kostl TO v_knttp.

WHEN 'P'.

MOVE lt_ekkn-ps_psp_pnr TO v_knttp.

WHEN 'O'.

MOVE lt_ekkn-aufnr TO v_knttp.

WHEN OTHERS.

MOVE lt_ekpo-knttp TO v_knttp.

ENDCASE.

write: v_knttp.

You will get a better picture thru code debug. Still if there is any issue, i think..you should paste the entire code piece.

Cheers,

Vikram

Pls reward for helpful replies!!