Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BDC for VA21

Former Member
0 Likes
641

Hi Friends:

I'm trying to make a BDC for VA21. I need to upload the description of the line items also. But in the recording its not taking the description text. I need to upload the same as well from flat file. Please help me on this.

1 REPLY 1
Read only

Former Member
0 Likes
429

hi sandeep,

Creating inbound call transaction logic

The second part of the create logic performs the operation of adding data to the SAP application database. You can use available functionality such as BAPIs and SAP standard functions or you can use custom-developed Call Transaction functionality. Keep in mind that if you use the available functionality, it may change in future releases. It is recommended that you use Call Transactions instead of writing to the database. Call Transactions allow you to develop custom functionality, independent of SAP database changes and specific to the scope and functionality you need.

To pass business object data into SAP, you can generate some of the ABAP code by using the Inbound Wizard in IBM WebSphere BI Station (transaction /n/CWLD/HOME), using the SAP BDC recorder, or developing it manually.

The Inbound Wizard records the activity for your create transaction and creates a text file with the BDC logic. For the Sales Quote example, transaction VA21 is recorded.

To record transaction VA21 using Inbound Wizard:

Go to IBM WebSphere BI Station (transaction /n/CWLD/HOME).

Important:

You must log on to the SAP system in English when using IBM WebSphere BI Station to generate business object definitions or ABAP handlers. The WebSphere BI Station log is available only in English.

On the Development tab, click the Inbound Wizard button.

Enter the following information:

Business object name--Name of the business object type as well as the name of every instance of the object. If you are creating a new business object, then enter a new name. It is recommended that you use a simple name that defines the business object. If you are using an existing business object, then select it from the drop-down list.

Verb--Verb supported by the business object.

Transaction code--Transaction code for the screen that supports the necessary functionality performed by the business object. To get the transaction code for a screen, Click Status from the System menu. The code is listed in the Transaction field under SAP data.

Click Record.

Step through the transaction that supports your business object functionality. Use all necessary fields and screens. When you are finished, save your transaction.

Choose the components that you want to include as metadata in your business object. Place your cursor on the component, and then click the Select/Deselect sub-tree button (F9). By default, all components are selected.

Generate a new dynamic object or source code.

To generate and insert the metadata for the Dynamic Transaction table, click the Generate Meta data button (F6). You can generate a WebSphere business object definition from this data.

To generate a text file with BDC data and field descriptions, click the Generate Code in Text File button (F5). You cannot generate a WebSphere business object definition from this data.

The following sample code is an excerpt from the first few lines of the generated BDC session:

  • Sales doc. Initial screen Create

perform dynpro_new using 'SAPMV45A' '0101' .

  • Sales document type

perform dynpro_set using 'VBAK-AUART' 'QT' .

  • Distribution channel

perform dynpro_set using 'VBAK-VTWEG' 'sourcefield' .

  • Division

perform dynpro_set using 'VBAK-SPART' 'sourcefield' .

  • Function Command

perform dynpro_set using 'BDC_OKCODE' '=ENT2' .

  • 4.0: Screen Container for Overview Screens (normal header)

perform dynpro_new using 'SAPMV45A' '4001' .

  • Sold-to party

perform dynpro_set using 'KUAGV-KUNNR' '238' .

  • Ship-to party

perform dynpro_set using 'KUWEV-KUNNR' '238' .

  • Function Command

perform dynpro_set using 'BDC_OKCODE' '=KKAU' .

  • 4.0: Screen container for document header screens

perform dynpro_new using 'SAPMV45A' '4002' .

  • Date until which bid/quotation is binding (valid-to date)

perform dynpro_set using 'VBAK-BNDDT' '20000630' .

You can also use SAP's BDC recorder (transaction SHDB). The following sample code was generated using the BDC recorder:

start-of-selection.

read dataset dataset into record.

if sy-subrc <> 0. exit. endif.

perform bdc_dynpro using 'SAPMV45A' '0101'.

perform bdc_field using 'BDC_CURSOR'

'VBAK-AUART'.

perform bdc_field using 'BDC_OKCODE'

'=ENT2'.

perform bdc_dynpro using 'SAPMV45A' '4001'.

perform bdc_field using 'BDC_OKCODE'

'=KKAU'.

perform bdc_field using 'BDC_CURSOR'

'KUWEV-KUNNR'.

perform bdc_field using 'KUAGV-KUNNR'

record-KUNNR_001.

perform bdc_field using 'KUWEV-KUNNR'

The output from this method does not have the business object comments from the first method and is less preferable. The advantage using SAP's BDC recorder is that it produces an independent method to verify your recording of BDC.

Another method is to generate the BDC manually. This is not an advised approach for the entire create functionality but rather as a supplement to the previous methods. It is useful when you need to add logic for additional screens or pop up boxes that may occur if the input data causes the SAP transaction to produce them.

IDoc handlers and the retrieve verbs

Object-specific IDoc handlers that support the Retrieve verb do not receive business object data from /CWLD/IDOC_HANDLER. Instead /CWLD/IDOC_HANDLER uses the OBJECT_KEY_IN parameter of the object-specific IDoc handler function to pass only the value of the first attribute marked IsKey. It is the object-specific IDoc handler's responsibility to use the value of this attribute to retrieve all information relevant to the instance of the business object using ABAP SQL, and to format that data in the appropriate IDoc structure.

Note:

In cases where the key is composed of multiple fields, the event detection mechanism (or, when the WebSphere InterChange Server is the integration broker, the map) concatenates the values of these fields into the first key attribute of the top-level business object. /CWLD/IDOC_HANDLER takes this concatenated key and loads it into its OBJECT_KEY_IN parameter. The object-specific IDoc handler must parse the value of the OBJECT_KEY_IN parameter into the multiple key fields. To maintain this functionality, it is important that you do not specify name-value pairs for the key when using /CWLD/IDOC_HANDLER.

The code fragment below illustrates an object-specific IDoc handler for retrieval of a Sales Quote. The Sales Quote business object retrieves data from tables VBAK, VBUK, VBPO, VBAP, VBUP, VBKD, KNOV, and VBPA. The tables follow the hierarchy and cardinality of IDoc type ZSLSQUOT. The code does the following:

Initializes global data.

Returns business object data from the SAP application database.

Builds an IDoc from the returned data and returns that data to /CWLD/IDOC_HANDLER.

The code fragment for an object-specific IDoc handler for IDoc type ZSLSQUOT is:

*- Clear the interface structures.

clear: g_text, object_key_out, return_code, return_text, idoc_data.

refresh: idoc_data.

  • If no key value is specified, log it as an error and exit.

if object_key_in is initial or

object_key_in = c_cxignore_const.

perform log_update(/cwld/sapllog) using c_error_log text-e02

space space space.

return_code = 1.

return_text = text-e02.

exit.

endif.

perform initialize_global_structures.

perform fill_internal_tables.

if not return_code is initial.

exit.

endif.

  • Build Idoc segments from internal tables

perform fill_idoc_inttab.

return_code = 0.

return_text = text-s01.

perform log_update(/cwld/sapllog) using c_information_log text-s01

space space space.

endfunction.

The two most important parameters are OBJECT_KEY_IN for the inbound key and IDOC_DATA for the outbound data. Note that OBJECT_KEY_IN may be a concatenated string that represents a multiple key (depending on the conventions you have defined). The object-specific IDoc handler parses the concatenated value and loads its parts into the appropriate key fields. To maintain this functionality, it is important that you do not specify name-value pairs for the key when using /CWLD/IDOC_HANDLER.

The VBAK table drives the selection criteria for the child tables, so each table is loaded into working tables. Using the VBAK table, you can retrieve the child tables with additional keys. So, for the Sales Quote example, the code is as follows:

form fill_internal_tables.

  • Get information from VBAK, VBUK, VBAP, VBKD, KONV, VBPA

select single * from vbak

where vbeln = object_key_in.

if sy-subrc <> 0.

perform log_update(/cwld/sapllog) using c_error_log text-e01

object_key_out c_blank c_blank.

return_code = '1'.

g_text = text-e01.

replace '&' with order_number into g_text.

return_text = g_text.

exit.

endif.

select single * from vbuk

where vbeln = vbak-vbeln.

select * from vbap into table t_vbap

where vbeln = vbak-vbeln.

  • Continue for other tables

The following code is used to copy the requested data from the application database into internal tables and working variables. Then it creates segments that directly correspond to the WebSphere business object definition and puts them into the SAP segment structure.

In some cases for close matches on fields between the IDoc type and the working structure, you can do an ABAP move-corresponding command. In other cases, it is preferable to manually move fields from the working table to the IDoc type table because of the relatively few fields to move in comparison to the overall number of fields in the structure. Simply, it is used to transfer data from the working data structures into the IDoc structures and then into the flat data field.

The code is:

form fill_idoc_inttab.

perform fill_zsqvbak. " Fill the Sales Quote Header

perform fill_zsqvbuk. " Fill the Sales Quote Status

perform fill_zsqvbap. " Fill Sales Quote Lines

endform. " FILL_IDOC_INTTAB

*-- fill the Sales Quote Header

form fill_zsqvbak.

clear idoc_data.

clear zsqvbak.

idoc_data-segnam = 'ZSQVBAK'.

move-corresponding vbak to zsqvbak.

move zsqvbak to idoc_data-sdata.

append idoc_data.

endform. " FILL_ZSQVBAK

*-- fill the Sales Quote Header Status

form fill_zsqvbuk.

clear idoc_data.

clear zsqvbuk.

idoc_data-segnam = 'ZSQVBUK'.

move-corresponding vbuk to zsqvbuk.

move zsqvbuk to idoc_data-sdata.

append idoc_data.

endform. " FILL_ZSQVBAK

*-- fill the Sales Quote Line and the Line Child segments

form fill_zsqvbap.

loop at t_vbap.

clear idoc_data.

clear zsqvbap.

idoc_data-segnam = 'ZSQVBAP'.

move-corresponding t_vbap to zsqvbap.

move zsqvbap to idoc_data-sdata.

append idoc_data.

perform fill_zsqvba2.

perform fill_zsqvbup.

perform fill_zsqvbkd.

perform fill_zsqkonv.

perform fill_zsqvbpa.

endloop.

endform.

*-- fill second part of vbap

form fill_zsqvba2.

thanks

karthik

reward me points if usefull

" etc.