VBAP, VBAK and KNA1
Hey SD experts,
I would like to link those three SAP tables :
VBAP, VBAK and KNA1 in order to create a query.
VBAP is the principal table, VBAK and KNA1 are additional ones.
What intermediate table should I use to make it possible ?
Thank you,
Bahia.
I'll explain to you in details:
I'm trying to create an infoset.
I choose "direct read of table" : VBAP
Than, I add VBAK : VBAP-VBELN = VBAK-VBELN
Than, KNA1: KNA1-KUNNR = VBAK-KUNNR
When I try to generate the infoset, I get this warning message:
Access error in code for table KNA1, KNA1 has sequence number 01
Fields from VBAK are not assigned to a field group
Fields from KNA1 are not assigned to a field group
Thank you
Similar Messages
-
Performance problems selecting form vbak and vbap
Hello,
I am try to select data from the vbak and vbap databasetables. The tables have more than a million of entries. I tried my best with two related selectstatements and the 'FOR All ENTRIES' syntax. The query takes more than 30 minutes. Is there a more efficient way than the following query, for example an inner join?. Tanks.
Regards, Lars.
FORM firstselect.
SELECT kvkorg kvtweg kspart kauart k~kunnr
kvsbed kaugru kvbeln kmandt
FROM VBAK AS k
INTO CORRESPONDING FIELDS OF TABLE t_outtab1
WHERE k~vkorg IN s_vkorg AND
k~vtweg IN s_vtweg AND
k~spart IN s_spart AND
k~auart IN s_auart AND
k~kunnr IN s_kunnr AND
k~vsbed IN s_vsbed AND
k~augru IN s_augru AND
k~vbeln IN s_vbeln.
ENDFORM.
FORM secondselect.
SELECT pposnr pvstel p~werks
pabgru pmatnr p~kwmeng
pzzurmeng pvrkme pmandt pvbeln
FROM VBAP AS p
INTO CORRESPONDING FIELDS OF TABLE t_outtab2
FOR ALL ENTRIES IN t_outtab1
WHERE
p~vstel IN s_vstel AND
p~werks IN s_werks AND
p~matnr IN s_matnr AND
p~abgru IN s_abgru AND
t_outtab1-mandt = p~mandt AND
p~vbeln = t_outtab1-vbeln.
ENDFORM.FORM firstselect.
SELECT vkorg
vtweg
spart
auart
kunnr
vsbed
augru
vbeln
mandt
FROM VBAK
INTO TABLE t_outtab1
WHERE vkorg IN s_vkorg AND
vtweg IN s_vtweg AND
spart IN s_spart AND
auart IN s_auart AND
kunnr IN s_kunnr AND
vsbed IN s_vsbed AND
augru IN s_augru AND
vbeln IN s_vbeln.
ENDFORM.
FORM secondselect.
SELECT posnr
vstel
werks
abgru
matnr
kwmeng
zzurmeng
vrkme
mandt
vbeln
FROM VBAP TABLE t_outtab2
FOR ALL ENTRIES IN t_outtab1
WHERE vbeln = t_outtab1-vbeln
AND vstel IN s_vstel AND
werks IN s_werks AND
matnr IN s_matnr AND
abgru IN s_abgru .
ENDFORM.
Hope this helps u.
I will get u back with more answers.
One more important thing see that the order which u r using in the select query is the same as that in the table this will affect the performs a lot.
<i><b>The first field should be the vbeln and then see the order and change that first and the same order should be in the internal table taht u r defining also.
If u do these things surely u can improve performance.</b></i>
Message was edited by: Judith Jessie Selvi -
Help needed for report on tables vbak and vbap
Hello,
I needed help in one of my work issues, this is my first project and Iam still learning. kindly help.
I was asked to take erdat,vbeln,posnr from selection screen and compare it with the data already in tables vbap,vbak. If the data
already exists and exception needs to be raised saying that the 'data exists',but if the data is not present in the tables the
tables have to be updated. This has to be done using function module only.
Then I have to write a REPORT calling the above function module and finally displaying the number of records updated and the
list of them.
I have started writing a function module:
FUNCTION z_tableupdate.
""Local Interface:
*" IMPORTING
*" VALUE(DATE) LIKE VBAK-ERDAT DEFAULT SY-DATUM
*" VALUE(SALESORDERNO) LIKE VBAK-VBELN
*" VALUE(ITEMNO) LIKE VBAP-POSNR
*" EXPORTING
*" VALUE(EX_VBAP) LIKE VBAP STRUCTURE VBAP
*" VALUE(SYS) LIKE SY-SYSID
*" VALUE(EX_VBAK) LIKE VBAK STRUCTURE VBAK
*" EXCEPTIONS
*" DATA_UPDATED
*" DATA_EXISTS
SELECT * FROM vbak INTO vbak_wa WHERE erdat = date
AND vbeln = salesorderno.
ENDSELECT.
SELECT * FROM vbap INTO vbap_wa WHERE posnr = itemno.
ENDSELECT.
IF sy-subrc EQ 0.
ex_vbap = vbap_wa.
ex_vbak = vbak_wa.
ELSE.
RAISE data_exists.
ENDIF.
sys = sy-sysid.
ENDFUNCTION.
How is the above code for function module, will this work??
Now can I write a report to call the above function module and update the record?? if so, how to update ??? please help...Lots of thanks in advance.Hi
Welcome to SDN forum
Whay can't you write a simple report in SE38.
why you are using Fun module
Nothing wrong in it.
But first become perfetc in reports in SE38 and then do using the fun modules
write a simple select statement like
SELECT AVBELN AERDAT BPOSNR BMATNR
INTO TABLE ITAB
FROM VBAK AS A JOIN VBAP ON
AVBELN = BVBELN
WHERE A~VBELN IN S_VBELN AND
A~ERDAT IN S_ERDAT AND
B~POSNR IN S_POSNR.
IF SY-SUBRC <> O.
WRITE: / 'No data found'.
ENDIF.
First write this in SE38 by defining a proper selection screen and internal tables
then do as fun module
see the doc for fun module
Function Modules;
Check this matter.
Function Modules are Global ABAP programs created by SAP for reusable purpose.they have IMPORT,EXPORT and TABLE parameters, and EXCEPTIONS to through when error occurs.
You can create them from TCode SE37.
Go through the following doc:
Function modules are cross-program, reusable procedures that are organized into function groups, and whose functions are implemented between the statements FUNCTION and ENDFUNCTION. Function modules and their interfaces are created in the Function Builder.
Function Module Interfaces
The parameter interface of a function module is defined in the Function Builder. It includes the definition of interface parameters and the specification of exceptions that can be triggered by a function module. The Function Builder automatically generates comment lines below the FUNCTION statement in the source code of the function module, which represent the interface of the function module with the following syntax:
Syntax
... [IMPORTING parameters]
[EXPORTING parameters]
[CHANGING parameters]
[TABLES table_parameters]
[{RAISING|EXCEPTIONS} exc1 exc2 ...]
The syntax and semantics of IMPORTING, EXPORTING, CHANGING, RAISING, and EXCEPTIONS mainly correspond to the definition of method interfaces with [CLASS-]METHODS. The additional option of defining table parameters using TABLES is obsolete.
Interface parameters
The interface parameters are defined on the relevant tab pages in the Function Builder.
IMPORTING parameters are input parameters. When the function module is called, a suitable actual parameter must be specified for every non-optional input parameter. The content of the actual parameter is passed to the input parameter when the call is made. The content of an input parameter for which 'pass by reference' is defined cannot be changed in the function module.
EXPORTING parameters are output parameters. When the function module is called, a suitable actual parameter can be specified for every output parameter. The content of an output parameter that is defined for 'pass by value' is transferred to the actual parameter if the function module is completed without errors. An output parameter that is defined for pass by reference is not initialized when the function module is called.
CHANGING parameters are input and output parameters. When the function module is called, a suitable actual parameter must be specified for every non-optional input or output parameter. When the function module is called, the content of the actual parameter is passed to the input/output parameter, and when the function module is completed, the content of the input/output parameter is passed to the actual parameter.
TABLES parameters are table parameters. Table parameters are obsolete CHANGING parameters that are typed as standard tables with a header line. If an internal table without a header line or a table body is passed as an actual parameter to a formal parameter of this type, an empty local header line is generated in the function module. If an internal table with a header line is used as an actual parameter, both the table body and the header line are passed to the function module. Pass by value is not possible in formal parameters defined using TABLES. Formal parameters defined with TABLES can be replaced by formal parameters defined with CHANGING. A local work area can be created for the internal table in the function module by using the addition LIKE LINE OF itab of the DATA statement.
Exceptions
The exception of a function module are defined on the Exceptions tab page in the Function Builder. Here you can select exception classes to define whether class-based exceptions are declared or non-class-based exception are defined. Class-based exceptions are represented in the above syntax by RAISING, and non-class-based exceptions are represented by EXCEPTIONS.
The addition RAISING is used to declare class-based exceptions that can be propagated from the function module to the caller. Exceptions in the categories CX_STATIC_CHECK and CX_DYNAMIC_CHECK must be explicitly declared, otherwise a propagation can lead to an interface violation. A violation of the interface leads to the treatable exception CX_SY_NO_HANDLER. Exceptions of the category CX_NO_CHECK are implicitly always declared. The declaration of exceptions of the category CX_STATIC_CHECK is statically checked in the syntax check. For exceptions of the category CX_DYNAMIC_CHECK, the check is not performed until runtime. In a function module in which class-based exceptions are declared with the RAISING addition, the statement CATCH SYSTEM-EXCEPTIONS cannot be used. Instead, the relevant treatable exceptions should be handled in a TRY control structure.
The addition EXCEPTIONS is used to define a list of non-class-based exceptions that can be triggered in the function module using the statements RAISE or MESSAGE RAISING. Exceptions defined in this way - as with formal parameters - are bound to the function module and cannot be propagated. If an exception of this type is triggered in a function module, and no return value has been assigned to it with the homonymous addition EXCEPTIONS of the CALL FUNCTION statement when the call was made, this leads to a runtime error.
Note
For new developments after release 6.10, SAP recommends that you work with class-based exceptions that are independent of the function module.
RFC is a technology which is used to access a functions (Modules) from
the remote systems.
If a function module is set as remote enabled which can be access from
the remote system via RFC.Eg: U can access the Remote enabled function modules in ur VB,Webdynpro,Java,Visual composer program.
A function module can be set as remote enabled by SE37->Go to ur FM->click the option Button "remote enabled".
But Normal function modules can not accessd from the remote system.
Good Example for RFC enabled function module is : BAPI(Business Application Programming Interface)
Note: All BAPIs are Remote enabled but not all remote enabled function modules are BAPI.
CALLING A FUNCTION MODULE:
1)In U ABAP Editor --> Click "Patter" ---> Selection Option Button "Call Function"
--> Write the Corresponding FM name --> Hit Enter
2)The appropriate import ,export Parameters will be displayed in ur editor
3)Pass the Values Here.
Also check these links.
http://www.geocities.com/victorav15/sapr3/abapfun.html
Check this link:
http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
Check this link:
http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
See the following links:
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
Regards
Anji -
Contract Sign Date from VBAK and VBAP and VEDA.
Hi ,
I need to fetch the Sales Document from VBAK and VBAP and VEDA with the contract sign date for sales document line item .
Contract sign date is in selection screen as select options.
Please let me know how to fetch the sales Document per line item from these 3 tables considering that A sales document could have many line items and each can have a different sign date.
Thanks
SachinHi,
The link between all the tables VBAK, VBAP and VEDA is VBELN i.e sales document number.
However, while fetching from VBAP and VEDA you would need to consider POSNR as well.
As your ABAPer to code the logic using 'for all entries' method.
Regards,
Amit
Edited by: Amit Iyer on Jun 23, 2011 12:28 PM -
Hi there!
When i want to extract data ,partly related to header and partly related to item , what i do is, i give the conditions(header conditions like sales org.) for which i need data in VBAK and when i get the sales order numbers i exceute VBAP for these sales order to get item data....is this the correct way or is there a way to get the header as well as item data from the same table....Please suggest....Dear Swetha,
If you want to pull data from a single table use T-code: SE16N.
If you want to join multiple Tables then create a Query thrrough SQ00. You can select the required feild in this Query & generate a report based on required selection criteria..
Hope this Helps..
Thanks,
Jignesh Mehta -
Hi Guys,
Can you pls check the query and suggest best approch to improve the performance as its going for dump.
VBAP as 2,22,34,404
VBAK as 25,54,345
and
r_matnr as 96,000 records.
SELECT vbapmatnr SUM( vbapkwmeng )
FROM vbak INNER JOIN vbap ON vbakvbeln = vbapvbeln
INTO TABLE t_xx
WHERE audat BETWEEN w_pstdat AND w_inidat
AND vkorg IN r_vkorg
AND auart IN r_auart
AND vbap~matnr IN r_matnr
AND vbap~werks EQ p_werks
AND vbap~pstyv IN s_pstyv
GROUP BY vbap~matnr.
Regards,
Srinivas M> Check for the View on VBAP AND VBAK that will help to increase the preformence
> instead of inner join
oh, a new option is recommended frequently in recent positing, after FAE is supported so much anymore.
BUT the View is only a dictionary defintion of a join, they are 100% identical on the database
There is not clear limit for the size of the ranges, usually in the order of 1000 or 2000. It will dump when whole resultings statement is above a limit, which is hard tto specify.
WHERE audat BETWEEN w_pstdat AND w_inidat
AND vkorg IN r_vkorg
AND auart IN r_auart
AND vbap~matnr IN r_matnr
AND vbap~werks EQ p_werks
AND vbap~pstyv IN s_pstyv
GROUP BY vbap~matnr.
This are actually several statements, which can be completely different. It depends which IN-Lists/Ranges are filled.
The join can react on that, it uses different accesses, if there are more conditions on vbak or
more vbap.
For the FAE you must programm two versions, one startung with vbak and one with vbak. And
you must determine which one will use. I doubt that you will better than the optimzer in the database.
Siegfried -
OBJNR is blank at VBAK and VBAP tables
Dear collegues,
There´s a strange situation on customer´s system. When end-user create a new quotation, the OBJNR field at VBAK and VBAP tables doesn´t fill itself, it remains blank. I believed that the field was filled when the document was saved. What´s wrong?
Regards, Otávio.Hi,
This might be due to many reasons.Please check if there any dumps related to it in ST22/SM21.
Also check if there any enough dialog/bckg work process to process the job.
filling up takes more time depending on the no of records in the application tables.
regards
Nagaraju -
Information about a VBAP, VBAK field...
Hello Experts-
I am working with a scenario where customer orders (sales transaction) are generated in a mySAP CRM 4.0 SP 3 system and are replicated to SAP R/3 Enterprise as sales orders.
Are any of you aware of a field in VBAK and/or VBAP in R/3 that keeps track of the document identifier from the CRM system?
Ideally, I need to be able to reconcile, at the line level, what object an entry in VBAP corresponds to an object identifier from the CRM system.
If not, it will be helpful, at the header level, to know which entry in VBAK corresponds to an object identifier from the CRM system.
I would appreciate your help.
Thank you,
- Vik.Hi Vik,
I have not had this scenario before, but try the following fields on VBAP:
VBELV May be your CRM reference Header
POSNV May be your CRM reference Item
VGBEL May be your CRM reference Header
VGPOS May be your CRM reference Item
Also have a look at the table VBFA (document flow) where:
VBELN is your sales order number
POSNN is your sales order item
VBELV may be your CRM reference header
POSNV may be your CRM reference item
Cheers,
Brad -
Joining the Tables VBAK and CDHDR
Hi All,
I am a novice to SAP, and probably have the most basic question. I need to join the two tables VBAK and CDHDR and I dont see any common fields between them.
I would need to do this for as generating a custom report that lists all the valid contracts created or changed within the period of selection. I also need to show the old value and the new value, the user ID of who made the change/creation and the date of the change.
Anyhelp in this regard is highly appreciated and will be rewarded appropriately.
Many thanks in anticipation.CDHDR is used for each and every table of SAP, so don't look for common key with your table.
Look for records in CDHDR with OBJECTCLAS = 'VERKBELEG' and OBJECTID = VBAK-VBELN, and then in CDPOS with keys of CDHDR and tabname = 'VBAK' and tabkey = VBAK-VBELN. (You also get VBAP and other tables under the same Id)
Take a look at report RVSCD100
Regards -
hi ..
I am working on project. I want to know the relationship between between the vbap vbak aukp cabnt and cawnt tables.
I want to get related data from all the mentioned tables through field augr in vbap which is for season in our project and kdmat which is style number.it is a garment industry project.
Please help me in doing this.Hi
VBAK and VBAP are sales order related Tables
we use CABN,CABNt and AUSP(it is not AUKP) for getting the characteristic data
Do you wants to fetch the Material characteristics or what?
better use the following
BAPI's:
BAPI_OBJCL_GETDETAIL
BAPI_OBJCL_CHANGE
or use the fun module:
CLAF_CLASSIFICATION_OF_OBJECTS.
Reward points for useful Answers
Regards
Anji -
Hi Experts,
IS there any link between VBAK and LIPS (VBELN AND VGBEL). Data is flow from header level VBAK to Item level LIPS is correct or Item level to item level.
Regards
RahulDear Rahul1234 ,
You can use the VBAK- VBELN or VBAP-VBELN
Put the same in VBFA as preceding document and fetch subsequent document where subsequent document category is J(delivery)
Now input that list in LIPS to get the required field.
This will work. If your ABAPer is telling that the logic is not correct, then you may demonstrate the same using a query (table join VBAK-VBFA-LIPS)
Thanks & Regards,
Hegal K Charles -
How to use Innerjoin b/w these 2 tables VBAK and CDHDR ?
Hi,
How to use Innerjoin b/w these 2 tables VBAK and CDHDR for retrieving of changed sales order data ?I nned the A select stmt with INNER JOIN for changed sales data.
Thanks & Regards,
gopi.Hi Gopi,
You can use the code similar to below to read the changes to Sales order from CDHDR AND CDPOS
FORM GET_CHANGES .
* Get all the changes to Sales Order as well as Deliveries. Suppress
* Non relevant change
DATA : BEGIN OF SO_VBELN OCCURS 0 ,
VBELN LIKE CDHDR-OBJECTID,
END OF SO_VBELN.
DATA : BEGIN OF DL_VBELN OCCURS 0 ,
VBELN LIKE CDHDR-OBJECTID,
END OF DL_VBELN.
DATA TEMP_SO_VBELN LIKE SO_VBELN OCCURS 0 WITH HEADER LINE.
DATA DATE_UNTIL LIKE SY-DATUM.
DATA TIME_UNTIL LIKE SY-UZEIT .
DATA DATE_FROM LIKE SY-DATUM.
READ TABLE S_CHADT INDEX 1.
LOOP AT IT_VBAP.
AT NEW VBELN.
MOVE IT_VBAP-VBELN TO TEMP_SO_VBELN.
COLLECT TEMP_SO_VBELN.
ENDAT.
ENDLOOP.
IF TEMP_SO_VBELN[] IS NOT INITIAL.
SELECT OBJECTID AS VBELN FROM CDHDR
INTO TABLE SO_VBELN
FOR ALL ENTRIES IN TEMP_SO_VBELN
WHERE OBJECTCLAS EQ 'VERKBELEG'
AND OBJECTID EQ TEMP_SO_VBELN-VBELN
AND USERNAME IN S_CHABY
AND UDATE IN S_CHADT.
ENDIF.
LOOP AT IT_LIPS INTO WA_LIPS.
AT NEW VBELN.
MOVE WA_LIPS-VBELN TO DL_VBELN.
COLLECT DL_VBELN.
ENDAT.
ENDLOOP.
* Changes in Sales Order.
IF NOT SO_VBELN[] IS INITIAL.
* Get partner functions
SELECT * INTO TABLE IT_TPART
FROM TPART WHERE SPRAS EQ SY-LANGU.
SELECT A~TABNAME A~FIELDNAME A~DATATYPE B~DDTEXT
INTO CORRESPONDING FIELDS OF TABLE IT_FIELD
FROM DD03L AS A INNER JOIN
DD04T AS B
ON A~ROLLNAME EQ B~ROLLNAME
AND A~AS4LOCAL EQ B~AS4LOCAL
WHERE ( A~TABNAME EQ 'VBAK'
OR A~TABNAME EQ 'VBAP'
OR A~TABNAME EQ 'VBEP'
OR A~TABNAME EQ 'VBPA'
OR A~TABNAME EQ 'VBUK'
OR A~TABNAME EQ 'VBKD' )
AND A~AS4LOCAL EQ 'A'
AND A~AS4VERS EQ '0000'
AND A~ROLLNAME NE SPACE
AND B~DDLANGUAGE EQ SY-LANGU.
* Preapare the exclusion table
R_EXCL_FIELDS-OPTION = 'EQ'.
R_EXCL_FIELDS-SIGN = 'I'.
LOOP AT IT_FIELD WHERE DATATYPE EQ 'CURR'.
R_EXCL_FIELDS-LOW = IT_FIELD-FIELDNAME.
APPEND R_EXCL_FIELDS.
ENDLOOP.
R_EXCL_FIELDS-LOW = 'ARKTX'.
APPEND R_EXCL_FIELDS.
R_EXCL_FIELDS-LOW = 'LGORT'.
APPEND R_EXCL_FIELDS.
R_EXCL_FIELDS-LOW = 'TDDAT'.
APPEND R_EXCL_FIELDS.
R_EXCL_FIELDS-LOW = 'LDDAT'.
APPEND R_EXCL_FIELDS.
R_EXCL_FIELDS-LOW = 'MBDAT'.
APPEND R_EXCL_FIELDS.
R_EXCL_TABL-OPTION = 'EQ'.
R_EXCL_TABL-SIGN = 'I'.
R_EXCL_TABL-LOW = 'KONVC'.
APPEND R_EXCL_TABL.
R_EXCL_TABL-LOW = 'VBKD'.
APPEND R_EXCL_TABL.
LOOP AT SO_VBELN.
REFRESH ITAB_CDHDR.
DATE_FROM = S_CHADT-LOW.
DATE_UNTIL = S_CHADT-HIGH.
CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
EXPORTING
DATE_OF_CHANGE = DATE_FROM
OBJECTCLASS = 'VERKBELEG'
OBJECTID = SO_VBELN-VBELN
TIME_OF_CHANGE = TIME_UNTIL
DATE_UNTIL = DATE_UNTIL
USERNAME = ' '
TABLES
I_CDHDR = ITAB_CDHDR
EXCEPTIONS
NO_POSITION_FOUND = 1
WRONG_ACCESS_TO_ARCHIVE = 2
TIME_ZONE_CONVERSION_ERROR = 3
OTHERS = 4.
IF SY-SUBRC NE 0.
CONTINUE.
ENDIF.
LOOP AT ITAB_CDHDR WHERE USERNAME IN S_CHABY.
REFRESH IT_CDSHW.
CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
EXPORTING
CHANGENUMBER = ITAB_CDHDR-CHANGENR
TABLES
EDITPOS = IT_CDSHW
EXCEPTIONS
NO_POSITION_FOUND = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC EQ 0.
PERFORM GET_ACTION .
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
* Changes in Delivery
IF NOT DL_VBELN[] IS INITIAL.
REFRESH : IT_CDHDR , IT_CDPOS.
SELECT OBJECTCLAS OBJECTID CHANGENR USERNAME UDATE
FROM CDHDR INTO CORRESPONDING FIELDS OF TABLE IT_CDHDR
FOR ALL ENTRIES IN DL_VBELN
WHERE OBJECTCLAS EQ 'LIEFERUNG'
AND OBJECTID EQ DL_VBELN-VBELN
AND USERNAME IN S_CHABY
AND UDATE IN S_CHADT
AND CHANGE_IND EQ 'U'.
LOOP AT IT_CDHDR.
CONCATENATE SY-MANDT IT_CDHDR-OBJECTID
INTO IT_CDHDR-TABKEY .
CONDENSE IT_CDHDR-TABKEY.
MODIFY IT_CDHDR.
ENDLOOP.
IF NOT IT_CDHDR[] IS INITIAL.
SELECT * INTO TABLE IT_CDPOS FROM CDPOS
FOR ALL ENTRIES IN IT_CDHDR
WHERE OBJECTCLAS EQ IT_CDHDR-OBJECTCLAS
AND OBJECTID EQ IT_CDHDR-OBJECTID
AND CHANGENR EQ IT_CDHDR-CHANGENR
AND TABNAME EQ 'LIKP'
AND TABKEY EQ IT_CDHDR-TABKEY
AND FNAME IN ('WADAT','LFDAT','ROUTE','VSBED')
AND CHNGIND EQ 'U' .
LOOP AT IT_CDPOS .
CLEAR IT_DL_CHG-FLAG_RED.
CASE IT_CDPOS-FNAME.
WHEN 'WADAT'.
MOVE 'Goods issue date changed' TO IT_DL_CHG-ACTION.
WHEN 'LFDAT'.
MOVE 'Delivery date changed' TO IT_DL_CHG-ACTION.
MOVE 'X' TO IT_DL_CHG-FLAG_RED.
WHEN 'ROUTE'.
MOVE 'Route Changed' TO IT_DL_CHG-ACTION.
WHEN 'VSBED'.
MOVE 'Shipping Condition Changed' TO IT_DL_CHG-ACTION.
WHEN OTHERS.
ENDCASE.
AT NEW CHANGENR .
READ TABLE IT_CDHDR WITH KEY OBJECTCLAS = IT_CDPOS-OBJECTCLAS
OBJECTID = IT_CDPOS-OBJECTID
CHANGENR = IT_CDPOS-CHANGENR
BINARY SEARCH.
MOVE IT_CDHDR-USERNAME TO IT_DL_CHG-ERNAM.
WRITE IT_CDHDR-UDATE TO IT_DL_CHG-ERDAT.
ENDAT.
IT_DL_CHG-COUNTER = IT_DL_CHG-COUNTER + 1.
MOVE IT_CDPOS-OBJECTID TO IT_DL_CHG-VBELN.
MOVE IT_CDPOS-VALUE_OLD TO IT_DL_CHG-OLD_VAL.
MOVE IT_CDPOS-VALUE_NEW TO IT_DL_CHG-NEW_VAL.
INSERT TABLE IT_DL_CHG.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM. " GET_CHANGES
Cheers
VJ -
SAP Query error for VBAK and KONV tables
Dear Experts,
Want to create SAP Query for below requirement but faced some error
Step1) Extract the data from VBAK table w.r.t. order type , Sale org and date range
and collected the Sales order numbers and doc. condition record (KNUMV)
Step 2)In table KONV (Transactional condition record data) in this table provided input as doc. condition record (KNUMV) with respect to condition type ABCD
Manually i extracted data, there is no problem .
But customer want to generate SAP Query for above requirement
I tried to create but in t.code SQ02 when i tried to join the table VBAK and KONV i faced the below error
Table KONV cannot be used in a join.
How can I create SAP query for above requirement ???
if its not possible then create Z report is the only solution ??????
Thanks in advanceHello
You can not create Query report with joining KONV. But there is one solution for your problem. You can create Query report by using Database VAV. In this logical database you will find all SD tables and also KONV. Use only those tables and fields which you want in your query report. I have checked this and its working
Please try this and update the forum accordingly.
Edited by: moazzamjii on Jun 30, 2011 12:13 PM -
Develop a form and print program using VBAP, VBAK, MRKT.
I have 2 tables VBAK [fields: VBELN, ERDAT, ERNAM, AUDAT, VBTYP, VKORG] and VBAP [Fields: POSNR, MATNR, CHARG, WAERK] and In output(form) i need the following fields,
Output table:
-VBELN
-ERDAT
-VKORG
-POSNR
-MATNR
-MAKTX <- this field is from table MAKT. (I need the Material descriptions too for all the materials.)
Form Layout should have Header, Logo (SAP ENJOY), Main, Footer.
Problem is that i need footer only after the End of Complete data in Main Window, thats is footer should be placed only in last window. How should i do that ?
Logic which i thot to make the print program is : First declare an internal table itab1 with VBAP, VBAP using the above fields from two tables and fetch the product based on matnr.
declare one internal table itab2 and select the records from the table makt by checking the condition itab1 is not initial.
sample code.
IF ITAB1 IS NOT INITIAL.
SELECT FIELD LIST FROM MAKT INTO TABLE ITAB2 WHERE MATNR EQ ITAB1-MATNR.
ENDIF.
hope this shuld work. ?????Hi
see the sample script program and do accordingly
*& Report ZTEST12121
*& SAPScripts Example 1
REPORT ztest12121.
*DATABASE TABLES
TABLES: ekko,ekpo,lfa1.
*INTERNAL TABLES AND STRUCTURES
DATA i_ekko LIKE ekko.
DATA i_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.
DATA i_lfa1 LIKE lfa1.
*PARAMETERS
PARAMETERS: p_ebeln LIKE ekko-ebeln.
*VARIABLES
DATA MAT TYPE STRING VALUE 'MAT NO'.
DATA iTe TYPE STRING VALUE 'ITEM NO'.
DATA QTY TYPE STRING VALUE 'QTY'.
DATA UOM TYPE STRING VALUE 'UOM'.
DATA NET TYPE STRING VALUE 'NET PRICE'.
Data var type integer value 0.
*DATABASE SELECTS
*Header data
SELECT SINGLE * FROM ekko INTO i_ekko WHERE ekko~ebeln = p_ebeln.
IF sy-subrc = 0.
*Item Data
SELECT * FROM ekpo INTO TABLE i_ekpo WHERE ekpo~ebeln = p_ebeln.
IF sy-subrc NE 0.
WRITE 'PURCHASE DOCUMENT ITEM DATA ERROR'.
ELSE.
*Vendor Details
SELECT SINGLE * FROM lfa1 INTO i_lfa1 WHERE lfa1~lifnr = i_ekko-lifnr.
IF sy-subrc NE 0.
WRITE 'VENDOR DOCUMENT ITEM DATA ERROR'.
ENDIF.
ENDIF.
ELSE.
WRITE 'THIS PURCHASE DOCUMENT NUMBER DOESNOT EXISTS'.
ENDIF.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
form = 'ZSCRIPT_1'
language = sy-langu
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
SPONUMIV =
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'OFFICEAD'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'OFFICEAD'
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'PODET'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'PODET'
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TOP'
FUNCTION = 'SET'
TYPE = 'TOP'
WINDOW = 'MAIN'
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT I_EKPO.
var = i_ekpo-netpr * i_ekpo-menge.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'BODY'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
OTFDATA =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Structure of a print program
OPEN_FORM function
CLOSE_FORM function
WRITE_FORM
START_FORM function
END_FORM function
CONTROL_FORM function
The print program is used to print forms. The program retieves the necesary data from datbase tables, defines the order of in which text elements are printed, chooses a form for printing and selects an output device and print options.
Function modules in a printprogram:
When you print a form you must used the staments OPEN_FORM and CLOSE_FORM. To combine forms into a single spool request use START_FORM and END_FORM.
To print textelements in a form use WRITE_FORM. The order in which the textelements are printed, is determined by the order of the WRITE_FORM statements. Note: for printing lines in the body, you can also use the WRITE_FORM_LINES function module.
To transfer control command to a form use CONTROL_FORM.
Structure of a print program
Read data
Tables: xxx.
SELECT *
FROM xxx.
Open form printing - Must be called before working with any of the other form function modules.
Must be ended with function module CLOSE FORM
call function 'OPEN_FORM'.....
To begin several indentical forms containing different data within a single spool request, begin each form using START_FORM, and end it using END_FORM
call funtion 'START_FORM'.....
Write text elements to a window of the form
call function 'WRITE_FORM'.....
Ends spool request started with START_FORM
call funtion 'END_FORM'.....
Closes form printing
call function 'CLOSE_FORM'...
OPEN_FORM function
Syntax:
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = ' '
LANGUAGE = SY-LANGU
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
OTHERS = 11
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Some important parameters:
FORM Name of the form
DEVICE PRINTER : Print output using spool
TELEFAX: Fax output
SCREEN: Output to screen
OPTIONS Used to control attrubutes for printing or faxing (Number of copies, immediate output....
The input for the parameter is structure ITCPO.
CLOSE_FORM function
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
OTFDATA =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Paramerters:
RESULT Returns status information and print/fax parameters after the form has been printed. RESULT is of structure ITCPP.
WRITE_FORM function
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = ' '
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
OTHERS = 9
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Some important parameters:
ELEMENT Specifies which textelement is printed
WINDOW Specifies which window is printed
TYPE Specifies the output area of the main window. This can be:
TOP - Used for headers
BODY
BOTTOM - Used for footers
FUNCTION Specifies whether text is to be appended, replaced or added
Example of how to use the WRITE_FORM function module together with a script.
Form layout of the MAIN window
/E INTRODUCTION
Dear Customer
/E ITEM_HEADER
IH Carrier, Departure
/E ITEM_LINE
IL &SBOOK-CARRID&, &SPFLI-DEPTIME&
/E CLOSING_REMARK
The print program
Writing INTRODUCTION
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'INTRODUCTION'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 8
Writing ITEM_HEADER
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM_HEADER'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 8
Set ITEM_HEADER into TOP area of main window for subsequent pages
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM_HEADER'
FUNCTION = 'SET'
TYPE = 'TOP'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 8
Write ITEM_LINE
LOOP AT .....
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM_LINE'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 8.
ENDLOOP.
Delete ITEM_HEADER from TOP area of main window
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM_HEADER'
FUNCTION = 'DELETE'
TYPE = 'TOP'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 8
Print CLOSING_REMARK
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CLOSING_REMARK'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
OTHERS = 8
START_FORM function
CALL FUNCTION 'START_FORM'
EXPORTING
ARCHIVE_INDEX =
FORM = ' '
LANGUAGE = ' '
STARTPAGE = ' '
PROGRAM = ' '
MAIL_APPL_OBJECT =
IMPORTING
LANGUAGE =
EXCEPTIONS
FORM = 1
FORMAT = 2
UNENDED = 3
UNOPENED = 4
UNUSED = 5
SPOOL_ERROR = 6
OTHERS = 7
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
END_FORM function
CALL FUNCTION 'END_FORM'
IMPORTING
RESULT =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SPOOL_ERROR = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CONTROL_FORM function
The CONTROL_FORM function module alows you to create SapScript control statements from within an APAB program.
Syntax:
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
command =
EXCEPTIONS
UNOPENED = 1
UNSTARTED = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Example:
Protecting the text element ITEM_LINE
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
COMMAND = 'PROTECT'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
TEXELEMENT = 'ITEM_LINE'.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
COMMAND = 'ENDPROTECT'.
Regards
Anji -
Inner joins on the tables VAKPA , VBAP and KNA1
HI ,
I have one performance issue.please see the below select query..In order to improve the performance i need to change this select query with out changing the functionality.Can any one of you please suggest me .
SELECT vakpakunde vakpaparvw kna1kunnr kna1name1 kna1~ktokd
vbapvbeln vbapposnr vbaparktx vbapzzclass
vbapmvgr2 vbapmvgr3 vbapmvgr5 vbapzzcanvas_year
vbapmatnr vbapmatkl
FROM vakpa
INNER JOIN vbap ON
vakpavbeln = vbapvbeln
INNER JOIN kna1 ON
vakpakunnr = kna1kunnr
INTO CORRESPONDING FIELDS OF TABLE gt_vbap
WHERE vakpa~kunde IN so_kunnr
AND vakpa~parvw = 'AG'
AND vakpa~vkorg IN so_vkorg
AND ( vbap~zzad_line_status = 'PR' OR
vbap~zzad_line_status = 'RE' )
AND vbap~mvgr5 IN r_ctf
AND vbap~matkl IN so_matkl
AND vbap~matnr IN so_matnr
AND vbap~zzcanvas_year IN so_year.
ENDIF.Use FOR ALL ENTRIES statement instead of joints.
or
and Remove INTO CORRESPONDING FIELDS by selecting the fields in the orderstored in table
Edited by: kalandar on Dec 4, 2009 7:43 AM
Maybe you are looking for
-
How can I use iweb 1.1.2 for more than one user account on my macbook?
I wonder if someone can guide me or point me to a previous answer on this, since I haven't found one. I'm simply trying to use iweb 1.1.2 on two user accounts (both labled as administrators) on our macbook. The program functions fine on one account,
-
System does not propose the delivery date based on factory calendar
Hi, I am creating a sales order for a delivery date for this sat which is (2/22/09) I have maintained 2 separate calendars for 1) shipping point 2) for the route The route has a transit time of 1 day and the calendar has sat and sunday as non working
-
Adjustment Brush coverage/Raw 7.1
Downloaded 7.1 beta to open Cr2 files from Canon 5D Mark3. Onle real hitch I have found in using the adjustment brush in Raw. With flow and density at 100%, minimal feathering, and brush hardness 100%, notice a lot of "speckling" where the affect has
-
Just bought a new computer How do I get all my music from old computer to the new one?
Bought a new computer with Windows 8. How do I get all the music off my old computer transferred to the new one. All the music on the old computer is in the cloud.
-
Performance of syncronous scenario
Hi, I need suggestions as to how to handle the following scenario. When a user enters data in one field (say employee number)of the SAP screen the data must be used in XI to call a webservice and get results(employee details) from it and fill up oth