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

Dynamic Case.

Former Member
0 Likes
1,341

Hello Gurus.

a short question. I's is possibel to create an Dynamical Case Condition.

For Example

Select * From HIT into table it_hit.

Case it_hit-number.

When '1: - Dynamic ???

When '2'

endase

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,099

Hi,

Yes it it possible, but not directly.

You will have to first put the code into an internal table,

then using GENERATE SUB ROUTINE POOL statement,

Create a dynamic program and call in background.

Regards,

Samson Rodrigues.

7 REPLIES 7
Read only

Former Member
0 Likes
1,100

Hi,

Yes it it possible, but not directly.

You will have to first put the code into an internal table,

then using GENERATE SUB ROUTINE POOL statement,

Create a dynamic program and call in background.

Regards,

Samson Rodrigues.

Read only

0 Likes
1,099

Hy Samson ,

that's a good idear. But its ab 4.6 System. I cant create Dynamic Tables.

Regards

Chris

Read only

0 Likes
1,099

Hey Chris,

I was not talking about dynamic tables,

create a table with only one field of 72 chars,

DATA: Begin of gt_itab occurs 0,

line(72) type c,

End of gt_itab.

data: gv_fname(30) type c value 'ZTEST_SAMSON', "program name

gv_err(120) type c, "error variable

then move all ur code into this, as if it is a program,

gt_itab-line = 'REPORT ZTEST_SAMSON.' .

append gt_itab .

gt_itab-line = 'FORM new_sub USING <some parameters>.' .

append gt_itab .

gt_itab-line = 'ur code here ' .

append gt_itab .

.........

keep adding lines of ur code to the table.

then close the sub routine

gt_itab-line = 'ENDFORM.'.

append gt_itab.

generate subroutine pool gt_itab name gv_fname message gv_err .

if sy-subrc eq 0.

perform new_sub in program (gv_fname) using <parameters>

if found.

write:/ gv_err .

clear gv_err.

else.

write:/ gv_err.

endif.

Regards,

Samson Rodrigues.

Read only

Former Member
0 Likes
1,099

Hi Christian,

try this short example:

tables: mara.

*

parameters: p_matkl0 like mara-matkl default '06'.

parameters: p_matkl1 like mara-matkl default '13'.

*

select * from mara up to 1000 rows.

case mara-matkl.

when p_matkl0.<b> "dynamic</b>

write: / p_matkl0, mara-matnr, mara-matkl.

when p_matkl1.<b> "dynamic</b>

write: / p_matkl1, mara-matnr, mara-matkl.

endcase.

endselect.

Regards, Dieter

Read only

0 Likes
1,099

Hello Dieter

I see no different between

p_matkl0 like mara-matkl default '06'

and

When '06'.

The Data are in a Table It_hit.

I want to youse the Date from the internen Tabel for the case.

Regards

Chris

Read only

0 Likes
1,099

Hi Christian,

p_matkl0 is an parameter. the value '06' is only default.

If you insert on schreen '10' the it mean When '10'. ...

Therefore i mean it's dynamic.

If you doesn't mean this, could you explane it a little bit more.

Regards, Dieter

Read only

0 Likes
1,099

Hello Dieter ,

there is a table with the data:

PREIS

LFDNR

TABNAME

FIELDNAME

FIELDNAME_REF

FAKTOR

I want This

Case FIELDNAME

when '1'

When '2'.

endcase.

Regards Chris