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

dyamic variable name

Former Member
0 Likes
322

Hi all,

I want to know if we can name variables dynamically. I am to create a report that summarizes the payment of all the employees against few suppliers.

Let me try to expain u

A supplier means essentially 2-3 wagetypes.

I have

1.Get pernr, Then I get itab1 which stores all the values for all wagetypes for an employee.

Now I loop through the suppliers and find the relevant wagetypes.

now i have itab2 with all the wagetypes i need.

Now

loop at itab1.

read itab2 wid wagetype itab1-wagetype.

this is all fine

Issue is where do is store value?

as in I cannot use a temporary variable since I dont knw

a. how many wagetypes a supplier mite have

Also I will have to loop through suppliers again and that would be a different set of wagetypes.

can I somehow name a variable such as it is dynamic

i.e temp_8790 for 8790

and temp_8779 for 8779?

thanks

HM

1 REPLY 1
Read only

Former Member
0 Likes
304

Instead of dynamic variable, you can store the values in a internal table(dynamicly created ) and the report summary will look like this: Hope this helpful.

Supplier | WagesType1 | WagesType2 | WagesType3 | ... |WagesTypeN|

-


There are already many posting on dynamic internal table. It is easy and this will

enhance readabilty of your report also.

First determine the maximun number of Wagestype (N).

Than in the fieldcatalog of the internal table(this is first step to dynamic internal table creation) declare the fields like

DATA: WAGESXXX(8) VALUE 'WAGESXXX',

WAGES_TYPE(8),

COUNT(3) TYPE N,

Do N times.

ADD 1 TO COUNT.

MOVE WAGESXXX TO WAGES_TYPE.

REPLACE 'XXX' WITH COUNT IN WAGES_TYPE.

WA_FIELDCAT-FIELDNAME = WAGES_TYPE (001 -


999)

-


-


-


APPEND WA_FIELDCAT TO TAB_FIELDCAT.

ENDDO.

Now you have a field of wages_type as many as you want for the report.

Regards,

Amarjit