cancel
Showing results for 
Search instead for 
Did you mean: 

creating a sales document using BAPI in web dynpro by uploading a file

Former Member
0 Kudos
92

Hi ALL,

Can some one help me how to create a sales document using BAPI by uploading a file as input...Can someone provide me a sample program....

Thanks n Regards,

Praveenn.

Edited by: praveenn on Aug 23, 2011 12:42 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member199125
Active Contributor
0 Kudos

Hi praveen,

You are just asking entire program. Its difficult to post here.

you can upload files using upload file UI element. And which files you are uploading?

You can use bapi in webdynpro using service call.

here is the link which is using service call.

http://www.saptechnical.com/Tutorials/WebDynproABAP/ALV/ServiceCall.htm

Just start your program step by step and let us know ur difficulties . forum will help you.

Regards

Srinivas

Former Member
0 Kudos

Hi Sri,

Thx for the response...

Here is the code that i followed for creating a BAPI_SALESORDER_CREATE1 by uploading a text file as input.

Just create a Attribute in the VIEW CONTEXT of type String.

method ONACTIONCREATE_SO .

types : Begin of ty_data,

sales_org type vkorg,

doc_type type AUART,

DISTR_CHAN type VTWEG,

DIVISION type spart,

material type matnr,

partn_role type PARVW,

PARTN_NUMB type kunnr,

end of ty_data.

DATA :it_table TYPE TABLE OF ty_data,

i_data TYPE TABLE OF string,

l_string TYPE string,

wa_table TYPE ty_Data,

l_xstring TYPE xstring,

fields TYPE string_table,

lv_field TYPE string.

DATA: wa_order_header_in TYPE BAPISDHD1,

it_order_items_in TYPE TABLE OF BAPISDITM,

wa_order_items_in TYPE BAPISDITM,

it_order_partners TYPE TABLE OF BAPIPARNR,

wa_order_partners TYPE BAPIPARNR,

it_return TYPE TABLE OF BAPIRET2,

wa_return TYPE BAPIRET2.

DATA : sales_doc type bapivbeln-vbeln.

  • DATA:

  • node_zfinal_node TYPE REF TO if_wd_context_node,

  • elem_zfinal_node TYPE REF TO if_wd_context_element,

  • stru_zfinal_node TYPE if_main_view=>element_zfinal_node .

  • get single attribute

wd_context->get_attribute(

EXPORTING

name = 'DATASOURCE'

IMPORTING

value = l_xstring ).

CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'

EXPORTING

in_xstring = l_xstring

IMPORTING

out_string = l_string.

SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.

LOOP AT i_data INTO l_string.

SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.

READ TABLE fields INTO lv_field INDEX 1.

wa_table-sales_org = lv_field.

READ TABLE fields INTO lv_field INDEX 2.

wa_table-doc_type = lv_field.

READ TABLE fields INTO lv_field INDEX 3.

wa_table-DISTR_CHAN = lv_field.

READ TABLE fields INTO lv_field INDEX 4.

wa_table-DIVISION = lv_field.

READ TABLE fields INTO lv_field INDEX 5.

wa_table-material = lv_field.

READ TABLE fields INTO lv_field INDEX 6.

wa_table-partn_role = lv_field.

READ TABLE fields INTO lv_field INDEX 7.

wa_table-partn_numb = lv_field.

APPEND wa_table TO it_table.

ENDLOOP.

loop at it_table into wa_table.

clear : wa_order_header_in.

wa_order_header_in-sales_org = wa_table-sales_org.

wa_order_header_in-doc_type = wa_table-doc_type.

wa_order_header_in-distr_chan = wa_table-distr_chan.

wa_order_header_in-division = wa_table-division.

clear : wa_order_items_in.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = wa_table-material

IMPORTING

OUTPUT = wa_order_items_in-material.

*wa_order_items_in-req_qty = wa_table-req_qty.

append wa_order_items_in to it_order_items_in.

clear : wa_order_partners.

wa_order_partners-partn_role = wa_table-partn_role.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = wa_table-partn_numb

IMPORTING

OUTPUT = wa_order_partners-partn_numb

.

*wa_order_partners-partn_numb = wa_table-partn_numb.

append wa_order_partners to it_order_partners.

endloop.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

  • SALESDOCUMENTIN =

order_header_in = wa_order_header_in

  • ORDER_HEADER_INX =

  • SENDER =

  • BINARY_RELATIONSHIPTYPE =

  • INT_NUMBER_ASSIGNMENT =

  • BEHAVE_WHEN_ERROR =

  • LOGIC_SWITCH =

  • TESTRUN =

  • CONVERT = ' '

IMPORTING

SALESDOCUMENT = sales_doc

tables

RETURN = it_return

ORDER_ITEMS_IN = it_order_items_in

  • ORDER_ITEMS_INX =

order_partners = it_order_partners.

  • ORDER_SCHEDULES_IN =

  • get message manager

DATA: l_current_controller TYPE REF TO if_wd_controller,

l_message_manager TYPE REF TO if_wd_message_manager.

l_current_controller ?= wd_this->wd_get_api( ).

DATA: v_message_text TYPE string.

  • When Sales Order is created commit the data

IF NOT sales_doc IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING wait = 'X'.

CONCATENATE 'Sales Document' sales_doc 'has been created.' INTO v_message_text SEPARATED BY space.

  • Report Success message

CALL METHOD l_message_manager->report_success

EXPORTING

message_text = v_message_text.

ELSE.

v_message_text = 'Error Creating Sales Order'.

  • Report Error message

CALL METHOD l_message_manager->report_error_message

EXPORTING

message_text = v_message_text.

ENDIF.

endmethod.

Edited by: praveenn on Aug 30, 2011 2:41 PM