11-20-2007 3:31 PM
Hi,
i will execute/modifiy the following code example to work dynamic. I mean that i want to configure how many fields and which field should be insert in the DB-Table
Samplecode:
LOOP AT vendor_tab INTO vendor_wa.
EXEC SQL.
insert into DatabaseTable.Dummy
(
ve_vendor_no,
ve_name,
ve_country
<b>.......(dynmaic)</b>
)
VALUES
(
:vendor_wa-a-lifnr,
:vendor_wa-a-name1,
:vendor_wa-a-land1
<b>............(dynamic)</b>
)
ENDEXEC.
ADD 1 TO commit_count.
IF commit_count EQ db_comit.
COMMIT WORK AND WAIT.
MOVE 0 TO commit_count.
ENDIF.
ENDLOOP.
If anyone has an idea it will be greatfull.
Thx
Joachim
11-20-2007 3:55 PM
Hi JWR,
Try this: build dynamically the part between the brackets ( ).
Define 2 string fields and concatenate inside what u need to build your SQL statement.
Then u'll have:
data: str1 type string,
str2 type string.
LOOP AT vendor_tab INTO vendor_wa.
build strings of fields - u cane move this part any where it suits
concatenate 've_vendor_no' 've_name' 've_country' .......(dynamic) into str1
separated by space.
concatenate ':vendor_wa-a-lifnr' ':vendor_wa-a-name1' ':vendor_wa-a-land1'
............(dynamic) into str2 separated by space.
EXEC SQL.
insert into DatabaseTable.Dummy
(
str1
)
VALUES
(
str2
)
ENDEXEC.
...
...
ENDLOOP.
Good luck
Pls reward if helps
Igal
11-20-2007 3:55 PM
Hi JWR,
Try this: build dynamically the part between the brackets ( ).
Define 2 string fields and concatenate inside what u need to build your SQL statement.
Then u'll have:
data: str1 type string,
str2 type string.
LOOP AT vendor_tab INTO vendor_wa.
build strings of fields - u cane move this part any where it suits
concatenate 've_vendor_no' 've_name' 've_country' .......(dynamic) into str1
separated by space.
concatenate ':vendor_wa-a-lifnr' ':vendor_wa-a-name1' ':vendor_wa-a-land1'
............(dynamic) into str2 separated by space.
EXEC SQL.
insert into DatabaseTable.Dummy
(
str1
)
VALUES
(
str2
)
ENDEXEC.
...
...
ENDLOOP.
Good luck
Pls reward if helps
Igal
01-09-2023 2:19 PM
Hello, Joachim!
Could you share the source code for the solution indicated by Igal, please? I did several tests, but all without success. Thank you very much01-12-2024 10:27 AM
Me too. It's not working. It says "Invalid column name 'str2'.