‎2008 Jul 19 8:26 PM
I have an additional question.
I'm allowing the User to maintain the Logic for assignments.
However, these do not go into the SQL Statement but should be checked as if they were a IF .....ENDIF statement.
I have assigned the field symbols that can fetch the value from the Work Area that has the entries to be compared.
RID PAR1 ANDOR FIELD OPER VALUE PAR2
R111 ( FSH_L3 = FS22500
R111 AND
R111 ( AUART = ZCS1
R111 OR AUART = ZCS2 )
R111 )
say, FSH_L3 = FS22500 and AUART = ZCS1This is how the condition string would look like
LF_STRING-COND = ( 'FS22500' = 'FS22500' AND ( 'ZCS1' = 'ZCS1' OR 'ZCS1' = 'ZCS2' ) )and the RID corresponding to it.
LF_STRING-RID = R111But i'm unable to use the If statement with a Dynamic logical expression.
IF (lf_string-cond).
RLID = LF_STRING-RID.
ENDIF.
So, is there anyway that i can validate the expression in my lf_string-cond to be true dynamically?
Thanks in advance,
RK.
‎2008 Jul 21 4:40 PM
If all else fails you could use dynamic program generation. You append your code lines similar to that example above with the syntax check, then use the statement GENERATE SUBROUTINE POOL to create a temporary subroutine which you can call using PERFORM ... IN PROGRAM ...
Good luck
Thomas
‎2008 Jul 19 8:38 PM
Please check the possibility to use MACRO for validation
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db972835c111d1829f0000e829fbfe/frameset.htm
a®
‎2008 Jul 19 9:10 PM
Thanks a®s.
I tried this code.
DATA: A type i value 1.
DATA: LF_STRING TYPE STRING.
DATA: RESULT TYPE BOOLEAN.
DEFINE VALIDATE.
IF &1.
result = 'X'.
ENDIF.
END-OF-DEFINITION.
LF_STRING = 'A = 1'.
VALIDATE LF_STRING.
And this Code:
TYPE-POOLS: abap.
DATA: lf_string TYPE string VALUE '1 = 2'.
DATA: if TYPE string VALUE 'IF'.
DATA: endif TYPE string VALUE 'ENDIF'.
DATA: set_result TYPE string VALUE 'RESULT = abap_true'.
DATA: result TYPE boolean.
DEFINE operation.
&1 &2.
&3.
&4.
END-OF-DEFINITION.
operation if lf_string set_result endif.But both give me the same error 'Incorrect logical expression.'
Edited by: RK on Jul 20, 2008 4:11 AM
‎2008 Jul 20 9:38 AM
Check out this code:
*&---------------------------------------------------------------------*
*& Report Z_TEST_SYNTAX_CHECK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_test_syntax_check.
DATA: itab1 TYPE STANDARD TABLE OF string,
itab2 TYPE STANDARD TABLE OF string,
mess TYPE string,
lin TYPE i,
wrd TYPE string,
dir TYPE trdir.
**********************************************************************
APPEND 'PROGRAM test.' TO itab1.
APPEND 'DATA dat TYPE d.' TO itab1.
APPEND 'DATA len TYPE c.' TO itab1.
APPEND 'DESCRIBE FIELD dat LENGTH len.' TO itab1.
SELECT SINGLE *
FROM trdir
INTO dir
WHERE name = sy-repid.
SYNTAX-CHECK FOR itab1 MESSAGE mess
LINE lin WORD wrd
DIRECTORY ENTRY dir.
IF sy-subrc = 4.
WRITE: /1 'Error in first program:' , mess.
ELSE.
WRITE: /1 'No error in first program'.
ENDIF.
**********************************************************************
APPEND 'PROGRAM test.' TO itab2.
APPEND 'DATA dat TYPE d.' TO itab2.
APPEND 'DATA len TYPE i.' TO itab2.
APPEND 'DESCRIBE FIELD dat LENGTH len IN byte MODE.' TO itab2.
SYNTAX-CHECK FOR itab2 MESSAGE mess
LINE lin WORD wrd
DIRECTORY ENTRY dir.
IF sy-subrc = 4.
WRITE : /1 'Error in second program:' , mess.
ELSE.
WRITE: /1 'No error in second program'.
ENDIF.
‎2008 Jul 20 1:14 PM
Thanks Sourav,
Thats a good one. However, my logic needs to occur many times .
The Original scenarion is that i have data to be analysed from GLPCA and each of these GLPCA Lines needs to be assigned one of the 50 predefined BucketIDs. This predefined logic can be changed at a later point of time. So based on the conditions that each of these IDs are defined upon, i have to assign the ID to the GLPCA line.
So in my case, I would have to identify if the GLPCA line would fit into which of the 50 Buckets. Which in turn means that i would have to create a maximum of such dynamic programs for each of the GLPCA line. And the number of records in GLPCA is itself very large. SO it'd be like creating ( 500,000 * 50 ) Programs internally. And that doesn't sound good to me.
Please suggest if i have misunderstood your advice .
Thanks again ,
RK.
‎2008 Jul 21 4:15 PM
Can a Where statement in a LOOP.... ENDLOOP be defined dynamically?
DO.
IF result = 'X'.
EXIT.
ENDIF.
LOOP AT lt_itab INTO lw_itab WHERE (lf_string) .
result = 'X'.
ENDLOOP.
ENDDO.When i do this, i get an error Statement concluding with "...(LF_STRING)" ended unexpectedly.
Please Advice.
RK
‎2008 Jul 21 4:40 PM
If all else fails you could use dynamic program generation. You append your code lines similar to that example above with the syntax check, then use the statement GENERATE SUBROUTINE POOL to create a temporary subroutine which you can call using PERFORM ... IN PROGRAM ...
Good luck
Thomas