03-07-2019 9:20 AM
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:
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
03-07-2019 9:29 AM
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...
03-07-2019 9:29 AM
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...
03-07-2019 9:50 AM
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
03-07-2019 11:17 AM
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.
03-07-2019 11:35 AM
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.