2008 Jun 02 12:23 PM
Hello,
I have a problem using workareas:
I want to use a internal table as a puffer:
Data:
BEGIN OF SAPOUTPUTtemp occurs 50,
PK like Zse11table-PK,
FNCODE like Zse11table-FNCODE,
END OF SAPOUTPUTtemp.Furthermore I define a work are like this:
DATA:
wa_Zse11table LIKE Zse11table.There is a database from se11 I read from:
SELECT * FROM zse11table into corresponding fields of table SAPOUTPUTtemp
WHERE STATE = '0'.So this code writes everything to my puffer.
Once I want to write the data from puffer to the workarea I wont get a error message but the contents of the workarea is empty:
LOOP AT SAPOUTPUTtemp.
wa_Zse11table-FNCODE = SAPOUTPUTtemp-FNCODE.
wa_Zse11table-MATNR = SAPOUTPUTtemp-MATNR.
Write : / 'Ouput:'.
skip.
write : / wa_Zse11table-FNCODE,
wa_Zse11table-MATNR,
wa_Zse11table-MAKTX,
wa_Zse11table-ZEINR,
wa_Zse11table-MATKL.
ENDLOOP.As I said the output is empty.
For the background understanding: I want use the workarea to UPDATE the se11 table afterwards. Therefore I copy all the dataset beside the one column I want to change. This one will get the new vallue.
Then I say:
UPDATE Zse11table FROM wa_Zse11table.Can you help me?
What is wrong with the work area?
Hello,
I have a problem using workareas:
I want to use a internal table as a puffer:
Data:
BEGIN OF SAPOUTPUTtemp occurs 50,
PK like Zse11table-PK,
FNCODE like Zse11table-FNCODE,
END OF SAPOUTPUTtemp.Furthermore I define a work are like this:
DATA:
wa_Zse11table LIKE Zse11table.There is a database from se11 I read from:
SELECT * FROM zse11table into corresponding fields of table SAPOUTPUTtemp
WHERE STATE = '0'.So this code writes everything to my puffer.
Once I want to write the data from puffer to the workarea I wont get a error message but the contents of the workarea is empty:
LOOP AT SAPOUTPUTtemp.
wa_Zse11table-FNCODE = SAPOUTPUTtemp-FNCODE.
wa_Zse11table-MATNR = SAPOUTPUTtemp-MATNR.
Write : / 'Ouput:'.
skip.
write : / wa_Zse11table-FNCODE,
wa_Zse11table-MATNR,
wa_Zse11table-MAKTX,
wa_Zse11table-ZEINR,
wa_Zse11table-MATKL.
ENDLOOP.As I said the output is empty.
For the background understanding: I want use the workarea to UPDATE the se11 table afterwards. Therefore I copy all the dataset beside the one column I want to change. This one will get the new vallue.
Then I say:
UPDATE Zse11table FROM wa_Zse11table.Can you help me?
What is wrong with the work area?
2008 Jun 02 12:31 PM
Hi
The internal table and work area declaration is different and hence u get errors..
You have declared ur internal table with only two fields-
Data:
BEGIN OF SAPOUTPUTtemp occurs 50,
PK like Zse11table-PK,
FNCODE like Zse11table-FNCODE,
END OF SAPOUTPUTtemp
whereas, the work area declaration has all the fields from the structure "Zse11table".
Correction:
Declare internal table like this:
DATA: SAPOUTPUTtemp like Zse11table occurs 50 with header line.
This will solve ur problem!
Thanks,
Shakir
**Award points if helpful
2008 Jun 02 12:33 PM
hi
i think insted of writing AS
LOOP AT SAPOUTPUTtemp.
write like
LOOP AT SAPOUTPUTtemp into wa_Zse11table.
then it shoud work.
NOTE : here u r internal table and Work Area must have the same
structure.
Note 2 . : if u r using Work Area then u not required to define Internal Table with Header Line .
reward if helpful.
2008 Jun 02 12:42 PM
thanks sachin, that was the problem.
@ the others: sorry I forgot to mention that I posted only parts of the code in this thread so it doesn't get too unclear.
thank you all.
edit:
I was too fast. That wasn't the point the values from the temp table a walk through are still empty.
I changed the problem another way that is not so performant but I don't find a better solution.
Edited by: Daniel Gerne on Jun 2, 2008 2:13 PM
2008 Jun 02 12:38 PM
Hi,
declare the internal table with header line........
You have internal table with 2 attributes and in the select statement
only 2 field get fetched.
so only....
wa_Zse11table-FNCODE,
wa_Zse11table-MATNR,
should come....but not
wa_Zse11table-MAKTX,
wa_Zse11table-ZEINR,
wa_Zse11table-MATKL.
also check out the update........
it is updating the dbtab with blank fields :
wa_Zse11table-MAKTX,
wa_Zse11table-ZEINR,
wa_Zse11table-MATKL.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2008 Jun 02 12:40 PM
Hi Daniel,
Try the below changed code
TYPES:
BEGIN OF ty_sapoutputtemp,
pk LIKE ztdm_sapoutput-pk,
fncode LIKE ztdm_sapoutput-fncode,
END OF ty_sapoutputtemp,
ty_ztdm_sapoutput TYPE zse11table.
DATA:
it_sapoutputtemp TYPE STANDARD TABLE OF ty_sapoutputtemp,
it_ztdm_sapoutput TYPE STANDARD TABLE OF ty_ztdm_sapoutput.
wa_sapoutputtemp type ty_sapoutputtemp,
wa_ztdm_sapoutput type ty_ztdm_sapoutput.
SELECT * FROM zse11table INTO CORRESPONDING FIELDS OF TABLE sapoutputtemp
WHERE state = '0'.
LOOP AT sapoutputtemp INTO wa_sapoutputtemp.
wa_ztdm_sapoutput-fncode = wa_sapoutputtemp-fncode.
wa_ztdm_sapoutput-matnr = wa_sapoutputtemp-matnr.
wa_ztdm_sapoutput-maktx = wa_sapoutputtemp-maktx.
wa_ztdm_sapoutput-zeinr = wa_sapoutputtemp-zeinr.
wa_ztdm_sapoutput-matkl = wa_sapoutputtemp-matkl.
INSERT wa_ztdm_sapoutput INTO it_ztdm_sapoutput.
CLEAR wa_ztdm_sapoutput.
OR.
Lock the data
Use your update statement
Release locked data
WRITE : / 'Ouput:'.
SKIP.
WRITE : / wa_ztdm_sapoutput-fncode,
wa_ztdm_sapoutput-matnr,
wa_ztdm_sapoutput-maktx,
wa_ztdm_sapoutput-zeinr,
wa_ztdm_sapoutput-matkl.
ENDLOOP.
LOck the custom table
MODIFY ztdm_sapoutput FROM TABLE it_ztdm_sapoutput .
Release the lock.
Hopes it will help for you.
Reward if it is helpful
Regards,
Boobalan Suburaj
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |