Hello,
I have a (maybe simple) problem:
I defined a table in se11.
I want to write a abap report to write datasets into it.
Therefore I created a workare and a string to count to the next Primary key (Primary Key is PK).
Once I write the table to screen it will only get me the first dataset I wrote to table. I am a beginner and don't know what I forgot. Do I need to do something like a db-commit?
My Code is:
TABLES ZTDM_SAPOUTPUT.
* Zeichenkette für den PK deklarieren
DATA:
zsapoutputPK LIKE ZTDM_SAPOUTPUT-MATNR.
* Arbeitsbereich definieren
DATA:
wa_ZTDM_SAPOUTPUT LIKE ZTDM_SAPOUTPUT.
WRITE: 'Ausgabe der Tabelle vor dem INSERT:'.
SKIP.
SELECT * FROM ZTDM_SAPOUTPUT.
Write: / ZTDM_SAPOUTPUT-FNCODE,
ZTDM_SAPOUTPUT-MATNR,
ZTDM_SAPOUTPUT-MAKTX,
ZTDM_SAPOUTPUT-ZEINR,
ZTDM_SAPOUTPUT-MATKL.
ENDSELECT.
SKIP.
* neuen Datensatz in Workarea schreiben
zsapoutputPK = ZTDM_SAPOUTPUT-PK.
zsapoutputPK = zsapoutputPK + 1.
wa_ZTDM_SAPOUTPUT-PK = zsapoutputPK.
wa_ZTDM_SAPOUTPUT-FNCODE ='ABCD'.
wa_ZTDM_SAPOUTPUT-MATNR ='ABCD'.
wa_ZTDM_SAPOUTPUT-MAKTX ='ABCD'.
wa_ZTDM_SAPOUTPUT-ZEINR ='ABCD'.
wa_ZTDM_SAPOUTPUT-MATKL ='ABCD'.
*INSERT-STATEMENT
INSERT ZTDM_SAPOUTPUT FROM wa_ZTDM_SAPOUTPUT.
* neuen Datensatz in Workarea schreiben
zsapoutputPK = zsapoutputPK + 1.
wa_ZTDM_SAPOUTPUT-PK = zsapoutputPK.
wa_ZTDM_SAPOUTPUT-FNCODE ='DEFG'.
wa_ZTDM_SAPOUTPUT-MATNR ='DEFG'.
wa_ZTDM_SAPOUTPUT-MAKTX ='DEFG'.
wa_ZTDM_SAPOUTPUT-ZEINR ='DEFG'.
wa_ZTDM_SAPOUTPUT-MATKL ='DEFG'.
*INSERT-STATEMENT
INSERT ZTDM_SAPOUTPUT FROM wa_ZTDM_SAPOUTPUT.
* Ausgabe nach INSERT
WRITE: 'Ausgabe der Tabelle NACH dem INSERT:'.
SKIP.
SELECT * FROM ZTDM_SAPOUTPUT.
Write: / ZTDM_SAPOUTPUT-FNCODE,
ZTDM_SAPOUTPUT-MATNR,
ZTDM_SAPOUTPUT-MAKTX,
ZTDM_SAPOUTPUT-ZEINR,
ZTDM_SAPOUTPUT-MATKL.
ENDSELECT.
The code should write 2 datasets to the table and then give the complete table to screen. Can you tell me my mistake?
Edited by: Daniel Gerne on May 30, 2008 9:46 AM