‎2009 Feb 03 4:43 AM
Dear All.
I have to add some extra validations in an existing SAP Query.
Current Scenario : Now the Query is fetching the details from the tables VBAK & VBAP.
Proposed : After fetching these details I need to check the following . Check whether the field (VBELN) is included in another table(Z-TABLE) or not. If it is there I have to remove that record.
How I will write the code?
Where can I write the code?
Please help me.
Regards,
Lijo
‎2009 Feb 03 5:00 AM
Hi Lijo,
Go to TCODE : SQ02. Give Infoset name. Under Data fields you will find technical names as VBAK , VBAP etc
Right click on VBAK and select "Code for record processing" . On the right the coding section will open up.
Regards
‎2009 Feb 03 4:54 AM
Hi Lijo,
-> After fetching the values from the table, put a select query on the Z-Table comparing the value of VBELN, and check for the SY-SUBRC value, if the value of SY-SUBRC = 0, record exist, oderwise it doesnt.
-> to remove the record from the Z-Table, use DELETE ZTable where vbeln = vbeln.
Hope this will work fine.
Regards
Karan Arya
‎2009 Feb 03 5:00 AM
Hello Karan,
Thanks for the reply.
My requirement is - Where can I write the code
In infoset(In which area)? SAP Query(In which area)?
or in Report Program which has been automatically generated from the Query?
Can you please let me know?
Regards,
Lijo.
‎2009 Feb 03 5:00 AM
Hi Lijo,
Go to TCODE : SQ02. Give Infoset name. Under Data fields you will find technical names as VBAK , VBAP etc
Right click on VBAK and select "Code for record processing" . On the right the coding section will open up.
Regards
‎2009 Feb 03 5:07 AM
Hi,
Write the above said logic in ,
Goto Tcode SQ02, select the reuired infoset, then click Change button,
Then Click on the required table and select the Code Button (Shift + F8) .
There in the drop down list in code section, select Record Processing,
then write your code.
Hope you clear in the steps.
‎2009 Feb 03 5:23 AM
Hey Lijo,
If u want to incorporate ur requirement in report program,, the following piece works:
TABLES: vbak, vbap, zvbak_t.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
DATA: BEGIN OF ztab occurs 0.
INCLUDE STRUCTURE zvbak_t.
DATA: END of ztab.
SELECT-OPTIONS: s_vbeln for VBAK-VBELN.
SELECT a~vbeln
b~posnr
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( VBAK AS a INNER JOIN VBAP AS b
ON a~vbeln = b~vbeln )
WHERE a~vbeln IN s_vbeln.
select * from zvbak_t into table ztab for all entries in itab where vbeln = itab-vbeln.
*loop at ztab.
*write:/ ztab-vbeln.
*endloop.
*
write:/ sy-dbcnt.
if sy-subrc = 0.
delete zvbak_t from table ztab.
endif.thanks\
Mahesh