2013 Aug 07 8:06 AM
Hi Experts,
I want to get string stored in a variable within program
scenerio
data: v_cmd(200) type c.
V_CMD = 'INSERT INTO AFRU1 (AUFNR,BUDAT,ERSDA,LMNGA,SMENG) VALUES (:<DYN_WA>-AUFNR,:<DYN_WA>-BUDAT,:
<DYN_WA>-ERSDA,:<DYN_WA>-LMNGA,:<DYN_WA>-SMENG).'.
Now i want to print this value
| INSERT INTO AFRU1 (AUFNR,BUDAT,ERSDA,LMNGA,SMENG) VALUES (:<DYN_WA>-AUFNR,:<DYN_WA>-BUDAT,: |
<DYN_WA>-ERSDA,:<DYN_WA>-LMNGA,:<DYN_WA>-SMENG).
purpose.
Execute Native SQL statement.
EXC SQL.
* If i pass here V_CMD.
* I get error.
* so i want to write text in bold.
ENDEXEC.
Please give me solution on urgent basis.
Support is appreciated.
Moderator message: What is urgent for you is not urgent for other members. Please read the forum RoE before posting.
Message was edited by: Suhas Saha
2013 Aug 07 10:43 AM
Hello Ranjit,
AFAIK native SQL construct does not support dynamic tokens. Alternatively you'll have to use ADBC classes to achieve your requirement.
BR,
Suhas
Hi Ranjit,
To Print the text in bold you can use format intensified
FORMAT INTENSIFIED ON.
WRITE <FIELD>.
FORMAT INTENSIFIED OFF.
2013 Aug 07 9:04 AM
(V_CMD) - this syntax will bring you the value of the string stored inside the variable.
So write your insert statement directly and if you get error
then write statement
Message v_cmd type e.
Hope this helps.
2013 Aug 07 11:53 AM
Hello Siddharth,
Syntax comes in V_CMD after concatenate and loop operation.
So I cant pass the insert statement directly within
EXEC SQL
...
..
ENDEXEC.
My code is :
DATA: CONNECTION LIKE DBCON-CON_NAME VALUE 'HEROPAY'.
DATA : V_CMD(200) TYPE C,
V_CMD1(200) TYPE C,
V_CNT(10) TYPE C,
V_RCNT(10) TYPE C,
V_EXCCMD(200) TYPE C.
EXEC SQL.
CONNECT TO :CONNECTION
ENDEXEC.
IF SY-SUBRC = 0.
EXEC SQL.
SET CONNECTION :CONNECTION
ENDEXEC.
V_RCNT = 1.
LOOP AT <DYN_TABLE> INTO <DYN_WA>.
V_CMD = 'INSERT INTO AFRU1 ('.
V_CMD1 = ' VALUES ('.
V_CNT = 1.
LOOP AT IDETAILS INTO XDETAILS.
IF V_CNT <> 1.
CONCATENATE V_CMD ',' INTO V_CMD.
CONCATENATE V_CMD1 ',' INTO V_CMD1.
ENDIF.
CONCATENATE V_CMD XDETAILS-NAME INTO V_CMD.
CONCATENATE V_CMD1 ':<DYN_WA>-' XDETAILS-NAME INTO V_CMD1.
V_CNT = V_CNT + 1.
ENDLOOP.
V_RCNT = V_RCNT + 1.
CONCATENATE V_CMD ')' V_CMD1 ')' INTO V_CMD." SEPARATED BY SPACE.
EXEC SQL.
ENDEXEC.
ENDLOOP.
EXEC SQL.
COMMIT
ENDEXEC.
EXEC SQL.
SET CONNECTION DEFAULT
ENDEXEC.
EXEC SQL.
DISCONNECT :CONNECTION
ENDEXEC.
ENDIF.
2013 Aug 07 9:04 AM
Hi Ranjit,
To Print the text in bold you can use format intensified
FORMAT INTENSIFIED ON.
WRITE <FIELD>.
FORMAT INTENSIFIED OFF.
2013 Aug 07 11:55 AM
Hello Chandresh,
I have to put insert statement stored in variable within
EXEC SQL.
........
ENDEXEC.
I have not to print this string.
Thanks for your reply.
2013 Aug 07 10:43 AM
Hello Ranjit,
AFAIK native SQL construct does not support dynamic tokens. Alternatively you'll have to use ADBC classes to achieve your requirement.
BR,
Suhas
2013 Aug 07 11:58 AM
Hello Suhas,
Could you please explain ADBC class in details, If possible.
As I have posted code above.
Your support is appreciated.
2013 Aug 07 1:10 PM
Hello Ranjit,
Please search for the relevant content on SCN. The usage of ADBC is highly documented in the forums.
BR,
Suhas
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |