2021 Sep 24 2:48 PM
Hello folks,
I'm currently working on to update the table in SAP db from the internal table.
First, I made an internal table from three different db tables.
TYPES: BEGIN OF GT_FINAL,
LFGJA TYPE MBEWH-LFGJA,
LFMON TYPE MBEWH-LFMON,
LBKUM TYPE MBEWH-LBKUM,
SALK3 TYPE MBEWH-SALK3,
VERPR TYPE MBEWH-VERPR,
STPRS TYPE MBEWH-STPRS,
PEINH TYPE MBEWH-PEINH,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKT-MAKTX,
END OF GT_FINAL.
DATA: IT_FINAL TYPE TABLE OF GT_FINAL,
WA_FINAL TYPE GT_FINAL.
SELECT A~LFGJA
A~LFMON
A~LBKUM
A~SALK3
A~VERPR
A~STPRS
A~PEINH
B~MATNR
B~MTART
C~MAKTX
APPENDING CORRESPONDING FIELDS OF TABLE IT_FINAL
FROM MBEWH AS A
INNER JOIN MARA AS B
ON A~MATNR = B~MATNR
INNER JOIN MAKT AS C
ON A~MATNR = C~MATNR
WHERE A~LFGJA EQ P_LFGJA
A~LFMON IN P_LFMON
B~MATNR IN P_MATNR.
DELETE FROM ZREPORT01_TABLE
WHERE LFGJA EQ P_LFGJA
AND LFMON IN P_LFMON
AND MATNR IN P_MATNR.
INSERT ZTABLE FROM IT_FINAL
And here is my problem comes.
First, I was trying to delete current db table.
Then, I was trying to update the db table from internal table in someway.
I got stuck because everytime I was trying to use,
INSERT ZTABLE FROM IT_FINAL.
I got error.
Overall, my question is.
how to update db table from internal table?
Thanks.
2021 Sep 24 3:28 PM
Basically the record of the internal table must match those of the database table
usually (easy way) the internal table is defined from the database table ddic definition
DATA: IT_FINAL TYPE TABLE OF ZTABLE.Read the documentation of Insert dbtab in SQL Abap and look for ABAP SQL - Work Areas in Statements.
Then either use the ddic table definition or adapt your internal table type to make it compliant with the database table
2021 Sep 24 2:49 PM
Thank you for visiting SAP Community to get answers to your questions. Since this is your first question, I recommend that you familiarize yourself with Community Q&A , as the overview provides tips for preparing questions that draw responses from our members.
Should you wish, you can revise your question by selecting Actions, then Edit.
By adding a picture to your Profile you encourage readers to respond.
2021 Sep 24 2:51 PM
2021 Sep 24 3:12 PM
2021 Sep 24 3:28 PM
Basically the record of the internal table must match those of the database table
usually (easy way) the internal table is defined from the database table ddic definition
DATA: IT_FINAL TYPE TABLE OF ZTABLE.Read the documentation of Insert dbtab in SQL Abap and look for ABAP SQL - Work Areas in Statements.
Then either use the ddic table definition or adapt your internal table type to make it compliant with the database table
2021 Sep 24 5:58 PM
2021 Sep 25 1:42 PM
"Got an error" is not a recognisable message. For all I know it means your computer explodes each time you try to run it.
2021 Sep 26 8:21 PM
2021 Sep 26 8:23 PM
I guess ZTABLE AND IT_FINAL internal table doesn't match.
In that case, then, I guess I should define this
DATA: IT_FINAL TYPE TABLE OF GT_FINAL,
WA_FINAL TYPE GT_FINAL.to this.
DATA: IT_FINAL TYPE TABLE OF ZTABLE,
WA_FINAL TYPE ZTABLE.But, then what about the GT_FINAL? It seems like that GT_FINAL is useless then.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |