‎2005 Aug 25 10:39 PM
Hi all,
I am wondering if there is a way to make a select out from a settings.
Scenario
-
I have a transparent table created as below:
MANDT
TABNAME
FIELDNAME
QUESTION
The purpose of the above transparent table is to store the question and answer. The answer is store in the specific field in the specific table.
Sample scenario will be:
-
Transparent table value:
TABNAME = PA0002
FIELDNAME = NACHN
QUESTION = 'What is your last name?'.
Programming logic:
1) Base on the question, the program will go to the field of the table specify above and look for the value and match with the answer key in.
Is there a way to do this? I would like to avoid using 'case' or 'if' statement.
I have tried to use field-symbols to do it but I failed. Any advice is appreciated
‎2005 Aug 26 5:21 AM
Hi,
Try this,
data : c_table(10) type c value 'MARA'.
data : c_field(10) type c value 'MATNR'.
data : c_CONDITION(25) type c value 'MATNR = ''AH0904001EN'''.
data : itab_mara like mara occurs 0 with header line.
select (C_FIELD) from (c_TABLE) into table itab_mara WHERE (C_CONDITION).
write itab_mara-matnr.
the same way you write as per your requirement
the above code working fine in 4.7 version.
Cheers,
Sasi
‎2005 Aug 25 11:14 PM
‎2005 Aug 26 4:42 AM
You can use a dynamic select:
REPORT ztest LINE-SIZE 132 MESSAGE-ID zc.
TABLES: ztest1.
DATA: BEGIN OF fields OCCURS 0,
field(80),
END OF fields.
DATA: BEGIN OF condition OCCURS 0,
field(80),
END OF condition.
DATA :answer(80).
SELECT * FROM ztest1 UP TO 1 ROWS.
* Here you need some logic to ask a question and return
* the answer - probably calling another screen. For now,
* we'll just fill it in. Then do some logic to format the
* answer into the proper format.
MOVE 'Smith' TO answer.
fields-field = ztest1-zz_xfield.
APPEND fields.
CONCATENATE ztest1-zz_xfield '= &'
INTO condition-field SEPARATED BY space.
CONCATENATE condition answer '&' INTO condition.
TRANSLATE condition USING '&'''.
APPEND condition.
SELECT (fields) FROM (ztest1-zz_table)
INTO answer
WHERE (condition).
ENDSELECT.
ENDSELECT.
‎2005 Aug 26 5:21 AM
Hi,
Try this,
data : c_table(10) type c value 'MARA'.
data : c_field(10) type c value 'MATNR'.
data : c_CONDITION(25) type c value 'MATNR = ''AH0904001EN'''.
data : itab_mara like mara occurs 0 with header line.
select (C_FIELD) from (c_TABLE) into table itab_mara WHERE (C_CONDITION).
write itab_mara-matnr.
the same way you write as per your requirement
the above code working fine in 4.7 version.
Cheers,
Sasi