03-15-2007 4:23 PM
I have a custom table ZTABLE (KUNNR, VBELN, ERDAT, ERZET, FLAG). I need to populate it with values from VBAK for all vbak-lifsk = 'Z7'
03-15-2007 8:22 PM
Hi Megan,
You may need to work with functional folks on output determination and find the appropriate one. You can use requirement (procedure) to call your program.
Anyhow ... please close the thread if your problem solved and reward points for all helpful answers
Regards,
Ferry Lianto
03-15-2007 4:29 PM
hi
try this:
first define ur internal table. flag has to be populated according to your requirement before inserting in to database table. or u can modify it after the required processes.
select kunnr vbeln erdat erzet
into corresponding fields of table itab
where lifsk = 'Z7'.
if sy-subrc = 0.
insert ztable from table itab.
endif.
**reward if helpful
regards,
madhu
03-15-2007 4:29 PM
Hi,
Please try this.
TABLES: VBAK, ZTABLE.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
DATA: BEGIN OF ITAB OCCURS 0,
KUNNR LIKE VBAK-KUNNR,
VBELN LIKE VBAK-VBLEN,
ERDAT LIKE VBAK-ERDAT
ERZET LIKE VBAK-ERZET
FLAG LIKE ZTABLE-FLAG.
DATA: END OF ITAB.
DATA: WA_ITAB LIKE ITAB.
SELECT KUNNR VBELN ERDAT ERZET
INTO TABLE ITAB
FROM VBAK
WHERE VBELN IN S_VEBLN
AND LIFSK = '27'.
LOOP AT ITAB INTO WA_ITAB.
WA_ITAB-FLAG = 'X'.
MODIFY ZTABLE FROM WA_ITAB.
ENDLOOP.
Regards,
Ferry Lianto
03-15-2007 4:33 PM
I am using my ZTABLE as a storage area itself so why do I need an itab
I was hoping for some syntax like
update ztable
set kunnr = vbak-kunnr,
vbeln = vbak-vbeln .. ..
where vbak-lifsk = 'z7'
but that doesnt work
03-15-2007 4:41 PM
Hi,
If you do not use internal table ITAB, how are you gonna collect the data from table VBAK and update ZTABLE?
Regards,
Ferry Lianto
03-15-2007 4:46 PM
update ztable.
set kunnr = vbak-kunnr,
vbeln = vbak-vbeln,
erdat = vbak-erdat,
erzet = vbak-erzet,
flag = space.
where vbak-lifsk = 'Z7'.
what is wrong with this code?
03-15-2007 4:50 PM
Hi,
Nothing wrong with your code if you have a single record that need to be update to ZTABLE.
But if you need to collect all information from VBAK and update the collected data to ZTABLE then you need to use internal table to store collected information.
If you don't want to use ITAB, perhaps you can try this.
DATA: WA_ITAB LIKE ITAB.
SELECT KUNNR VBELN ERDAT ERZET
INTO (WA_ITAB-KUNNR, WA_ITAB-VBELN, WA_ITAB-ERDAT,WA_ITAB-ERZET)
FROM VBAK
WHERE VBELN IN S_VEBLN
AND LIFSK = '27'.
UPDATE ZTABLE FROM WA_ITAB.
ENDSELECT.
Regards,
Ferry Lianto
03-15-2007 6:06 PM
yeah i do need to collect all information and not just one record
Should I just go ahead and use this then. Why are you using Select-Options
TABLES: VBAK, ZTABLE.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
DATA: BEGIN OF ITAB OCCURS 0,
KUNNR LIKE VBAK-KUNNR,
VBELN LIKE VBAK-VBLEN,
ERDAT LIKE VBAK-ERDAT
ERZET LIKE VBAK-ERZET
FLAG LIKE ZTABLE-FLAG.
DATA: END OF ITAB.
DATA: WA_ITAB LIKE ITAB.
SELECT KUNNR VBELN ERDAT ERZET
INTO TABLE ITAB
FROM VBAK
WHERE VBELN IN S_VEBLN
AND LIFSK = '27'.
LOOP AT ITAB INTO WA_ITAB.
WA_ITAB-FLAG = 'X'.
MODIFY ZTABLE FROM WA_ITAB.
ENDLOOP.
03-15-2007 6:14 PM
Hi Megan,
Why are you using Select-Options?
Just for testing purposes. In case you want to test with couple documents before you do mass update.
Regards,
Ferry Lianto
03-15-2007 6:24 PM
SELECT KUNNR, VBELN, ERDAT, ERZET
INTO TABLE ITAB
FROM VBAK
WHERE VBELN IN S_VEBLN
AND LIFSK = 'Z7'.
What is wrong with this code
It says Comma without preceding colon (after Select ?)
03-15-2007 6:29 PM
hi megan,
u should not use comma in between the field name in the select statement.
u have to use like this.
SELECT KUNNR VBELN ERDAT ERZET
INTO TABLE ITAB
FROM VBAK
WHERE VBELN IN S_VEBLN
AND LIFSK = 'Z7'.
Regards...
Arun.
03-15-2007 6:28 PM
Hi,
Please remove coma in this line.
SELECT KUNNR, VBELN, ERDAT, ERZET
It should be ...
SELECT KUNNR VBELN ERDAT ERZET
Regards,
Ferry Lianto
03-15-2007 6:35 PM
SELECT KUNNR VBELN ERDAT ERZET
INTO TABLE ITAB
FROM VBAK
WHERE VBELN IN S_VEBLN
AND LIFSK = 'Z7'.
Error: The IN operator with "S_VEBLN" is followed neither by an internal table
nor by a value list.
03-15-2007 6:37 PM
Hi,
You had typo error.
S_VEBLN
it should be ...
S_VBELN
Please cut and paste above my codes ...
Regards,
Ferry Lianto
03-15-2007 6:43 PM
Thank you Ferry!! My brain is dead today
I shall be awarding points to you all once I get this working in a few mins
03-15-2007 8:16 PM
Hi Ferry
Your code works fine. The functional dude wants to now include the delivery block condition in the output determination which will call a transaction that will call this program, so I will have to remove the condition. More on that later. But for now, thank you!
Btw, do you know how output determination would work in this case. Basically whenever delivery block gets activated it will trigger a transaction which should populate my custom table from VBAK. I have still to understand how my program fits into this scheme.
03-15-2007 8:22 PM
Hi Megan,
You may need to work with functional folks on output determination and find the appropriate one. You can use requirement (procedure) to call your program.
Anyhow ... please close the thread if your problem solved and reward points for all helpful answers
Regards,
Ferry Lianto