Application Development 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: 

How best to process variable fields

former_member201275
Active Contributor
0 Kudos
162

Hi,

We have a report which delivers an output structure, and I have to add in another field (this example OUTPUT_FIELD) and populate this field depending on variable criteria.

The customer will supply me a table as follows:

capture.png

I must then, using the first row as an example, provide code that if PA0001-PERSG = A001, and PA0002-LAND = DE, and PA9006-DEPARTMENT = 'FI001', then the new field OUTPUT_FIELD = D010GL,

etc....

How best do i handle this scenario? I never know in advance what the variables might be, and in some cases, for example the second line for variable 3 there is no value.

Is it best to use 'ASSIGN COMPONENTS', or is there a neater/better way to do this.

All help and advice is really greatly appreciated!

Thank you and kind regards

Glen

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos
79

So, the question is "dynamic" (var = 'PA0002-XXXX'. ASSIGN (var) TO <fs>) or "static" access (if var1-field = 'PA0002-XXXX'. pa0002-xxxx = ...)

If there's a limited number of possible fields, then static, otherwise dynamic.

I don't think you have a lot of possibilities...

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos
80

So, the question is "dynamic" (var = 'PA0002-XXXX'. ASSIGN (var) TO <fs>) or "static" access (if var1-field = 'PA0002-XXXX'. pa0002-xxxx = ...)

If there's a limited number of possible fields, then static, otherwise dynamic.

I don't think you have a lot of possibilities...

former_member259807
Active Participant
0 Kudos
79

Is there a possibility for you to create a (SM30) custom table with a number of 'field' fields and 'value' fields and the last field being the output field?

You can then just loop over the custom table, comparing the fields and values (using field symbols). If a row complies, fill the output field with the related value of your custom table.

So something like this:

field1 type NAME_FELD
value1 type c length whatever
field2 type NAME_FELD
value2 type c length whatever
field3 type NAME_FELD
value3 type c length whatever
field4 type NAME_FELD
value4 type c length whatever
(etc)
output_field type c length whatever

former_member201275
Active Contributor
0 Kudos
79

Thank you both for your answers! 🙂

Sorry I should have said that; I will be provided wih a customizing table (SM30) in the format as per the screenshot I provided.

DoanManhQuynh
Active Contributor
79

So you have to select data from customzing table, get the field name and assign component of structure that you need to check, get value of that component and compare, field symbol is your friend here.