Bapi Dialog

  • Upload
    anil

  • View
    279

  • Download
    2

Embed Size (px)

Citation preview

  • 7/25/2019 Bapi Dialog

    1/22

    3.BAPI- Difference Between Non Dialog & Dialog BAPI with example.Dialog BAPIs usually calls the Screen where the user is required and it can not be executed

    in background where as with Non Dialog BAPIs can be called in Background mode without

    any User intervention. The below post shows the difference between the two types.

    --------------------------------------------------------------------------------------------------------------

    Step1. Go to Tx- SWO1 & open the BO- BUS2032 Sales order. The two methods creates

    the Sales Order but one without dialog mode and other is with dialog mode.

    Step2. The associated FMs with the BAPI Methods.

    http://freesapabap.blogspot.com/2014/06/3bapi-difference-between-non-dialog.htmlhttp://freesapabap.blogspot.com/2014/06/3bapi-difference-between-non-dialog.html
  • 7/25/2019 Bapi Dialog

    2/22

    Step3. Create the below report which created the Sales Order By Non Dialog BAPI FM call.

    _________________________________________________________________________

    ________

    PARAMETERS : p_no_so TYPE int4.

    DATA : ls_ord_hdr TYPE bapisdhd1,

    ls_ord_hdrx TYPE bapisdhd1x,

    so_num TYPE bapivbeln-vbeln,

    lt_so_num LIKE TABLE OF so_num,

    lt_ret TYPE TABLE OF bapiret2,

    lt_item TYPE TABLE OF bapisditm,

    ls_item TYPE bapisditm,

    lt_itemx TYPE TABLE OF bapisditmx,

    ls_itemx TYPE bapisditmx,

    lt_part TYPE TABLE OF bapiparnr,

    ls_part TYPE bapiparnr,

    lt_schd TYPE TABLE OF bapischdl ,

  • 7/25/2019 Bapi Dialog

    3/22

    ls_schd TYPE bapischdl,

    lt_schdx TYPE TABLE OF bapischdlx,

    ls_schdx TYPE bapischdlx.

    START-OF-SELECTION.

    ******* Fill the Sales Order Header ****************

    ls_ord_hdr-doc_type = 'TA'. " ORDER Type : OR->TA as per TVAK table

    ls_ord_hdr-sales_org = 'AB99'.

    ls_ord_hdr-distr_chan = 'WS'.

    ls_ord_hdr-division = 'LT'.

    ls_ord_hdr-purch_no_c = 'ORDER_100'.

    ls_ord_hdrx-updateflag = 'X'.

    ls_ord_hdrx-doc_type ='X'.

    ls_ord_hdrx-sales_org = 'X'.

    ls_ord_hdrx-distr_chan = 'X'.

    ls_ord_hdrx-division = 'X'.

    ls_ord_hdrx-purch_no_c = 'X'.

    *********FILL PARTNERS TABLE ******************

    ls_part-partn_role = 'AG'. " SOLD TO PARTY

    ls_part-partn_numb = '0000099994'.

    APPEND ls_part TO lt_part.

    CLEAR ls_part.

    ls_part-partn_role = 'RE'. " BILL TO PARTY

    ls_part-partn_numb = '0000099996'.

    APPEND ls_part TO lt_part.

    CLEAR ls_part.

    ls_part-partn_role = 'RG'. " PAYERls_part-partn_numb = '0000099997'.

    APPEND ls_part TO lt_part.

    CLEAR ls_part.

    ls_part-partn_role = 'WE'. " SHIP TO PARTY

    ls_part-partn_numb = '0000099995'.

  • 7/25/2019 Bapi Dialog

    4/22

    APPEND ls_part TO lt_part.

    CLEAR ls_part.

    *********FILL ITEMS ***********************

    ls_item-itm_number = '10'.ls_item-material = '000000000000001278'.

    ls_item-plant = 'PLBN'.

    ls_item-target_qty = '10'.

    ls_item-target_qu = 'EA'.

    APPEND ls_item TO lt_item.

    CLEAR : ls_item.

    ls_itemx-itm_number = '10'.

    ls_itemx-material = 'X'.

    ls_itemx-plant = 'X'.

    ls_itemx-target_qty = 'X'.

    ls_itemx-target_qu = 'X'.

    APPEND ls_itemx TO lt_itemx.

    CLEAR : ls_itemx.

    ******* SCHEDULE LINE *********************

    ls_schd-itm_number = '10'.

    ls_schd-req_qty = '10'.

    APPEND ls_schd TO lt_schd.

    CLEAR ls_schd.

    ls_schdx-itm_number = '10'.

    ls_schdx-req_qty = 'X'.

    ls_schdx-updateflag = 'X'.

    APPEND ls_schdx TO lt_schdx.

    CLEAR ls_schdx.

    IF p_no_so > 0.

    DO p_no_so TIMES.

    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

    EXPORTING

    order_header_in = ls_ord_hdr

    order_header_inx = ls_ord_hdrx

  • 7/25/2019 Bapi Dialog

    5/22

    IMPORTING

    salesdocument = so_num

    TABLES

    return = lt_ret

    order_items_in = lt_item order_items_inx = lt_itemx

    order_partners = lt_part

    order_schedules_in = lt_schd

    order_schedules_inx = lt_schdx.

    IF sy-subrc = 0.

    APPEND so_num TO lt_so_num.

    CLEAR so_num.

    COMMIT WORK.

    ENDIF.

    ENDDO.

    ENDIF.

    END-OF-SELECTION.

    IF lt_so_num IS NOT INITIAL.

    LOOP AT lt_so_num INTO so_num.

    WRITE :/ 'Sales Order Generated By BAPI call-', sy-tabix , ':', so_num.

    ENDLOOP.

    ENDIF.

    _________________________________________________________________________

    _______

    Step4. Create the below report which created the Sales Order By Dialog BAPI FM call.

    _________________________________________________________________________

    ________

    PARAMETERS : p_no_so TYPE int4.

    DATA : ls_ord_hdr TYPE bapisdhead1,

    ls_ord_hdrx TYPE bapisdhead1x,

    so_num TYPE bapivbeln-vbeln,

    lt_so_num LIKE TABLE OF so_num,

    lt_ret TYPE TABLE OF bapiret2,

    lt_item TYPE TABLE OF bapisditem,

  • 7/25/2019 Bapi Dialog

    6/22

    ls_item TYPE bapisditem,

    lt_itemx TYPE TABLE OF bapisditmx,

    ls_itemx TYPE bapisditmx,

    lt_part TYPE TABLE OF bapipartnr,

    ls_part TYPE bapipartnr, lt_schd TYPE TABLE OF bapischedule,

    ls_schd TYPE bapischedule,

    lt_schdx TYPE TABLE OF bapischedulex,

    ls_schdx TYPE bapischedulex.

    START-OF-SELECTION.

    ******* Fill the Sales Order Header ****************

    ls_ord_hdr-doc_type = 'TA'. " ORDER Type : OR->TA as per TVAK table

    ls_ord_hdr-sales_org = 'AB99'.

    ls_ord_hdr-distr_chan = 'WS'.

    ls_ord_hdr-division = 'LT'.

    ls_ord_hdr-purch_no_c = 'ORDER_100'.

    ls_ord_hdrx-doc_type ='X'.

    ls_ord_hdrx-sales_org = 'X'.

    ls_ord_hdrx-distr_chan = 'X'.

    ls_ord_hdrx-division = 'X'.

    ls_ord_hdrx-purch_no_c = 'X'.

    *********FILL PARTNERS TABLE ******************

    ls_part-partn_role = 'AG'. " SOLD TO PARTY

    ls_part-partn_numb = '0000099994'.

    APPEND ls_part TO lt_part.

    CLEAR ls_part.

    ls_part-partn_role = 'RE'. " BILL TO PARTY

    ls_part-partn_numb = '0000099996'.APPEND ls_part TO lt_part.

    CLEAR ls_part.

    ls_part-partn_role = 'RG'. " PAYER

    ls_part-partn_numb = '0000099997'.

  • 7/25/2019 Bapi Dialog

    7/22

    APPEND ls_part TO lt_part.

    CLEAR ls_part.

    ls_part-partn_role = 'WE'. " SHIP TO PARTY

    ls_part-partn_numb = '0000099995'.APPEND ls_part TO lt_part.

    CLEAR ls_part.

    *********FILL ITEMS ***********************

    ls_item-itm_number = '10'.

    ls_item-material = '000000000000001248'.

    ls_item-plant = 'PLBN'.

    ls_item-target_qty = '10'.

    ls_item-target_qu = 'EA'.

    APPEND ls_item TO lt_item.

    CLEAR : ls_item.

    ls_itemx-itm_number = '10'.

    ls_itemx-material = 'X'.

    ls_itemx-plant = 'X'.

    ls_itemx-target_qty = 'X'.

    ls_itemx-target_qu = 'X'.

    APPEND ls_itemx TO lt_itemx.

    CLEAR : ls_itemx.

    ******* SCHEDULE LINE *********************

    ls_schd-itm_number = '10'.

    ls_schd-req_qty = '10'.

    APPEND ls_schd TO lt_schd.

    CLEAR ls_schd.

    ls_schdx-itm_number = '10'.ls_schdx-req_qty = 'X'.

    ls_schdx-updateflag = 'X'.

    APPEND ls_schdx TO lt_schdx.

    CLEAR ls_schdx.

    IF p_no_so > 0.

  • 7/25/2019 Bapi Dialog

    8/22

    DO p_no_so TIMES.

    CALL FUNCTION 'BAPI_SALESDOCU_CREATEWITHDIA' " Calls VA01 Transaction

    EXPORTING

    sales_header_in = ls_ord_hdr sales_header_inx = ls_ord_hdrx

    IMPORTING

    SALESDOCUMENT_EX = so_num

    TABLES

    return = lt_ret

    sales_items_in = lt_item

    sales_items_inx = lt_itemx

    sales_partners = lt_part

    sales_schedules_in = lt_schd

    sales_schedules_inx = lt_schdx.

    IF sy-subrc = 0.

    APPEND so_num TO lt_so_num.

    CLEAR so_num.

    COMMIT WORK.

    ENDIF.

    ENDDO.

    ENDIF.

    END-OF-SELECTION.

    IF lt_so_num IS NOT INITIAL.

    LOOP AT lt_so_num INTO so_num.

    WRITE :/ 'Sales Order Generated By BAPI call-', sy-tabix , ':', so_num.

    ENDLOOP.

    ENDIF.

    _________________________________________________________________________________

    Step5. Execute both the report and see the output.

  • 7/25/2019 Bapi Dialog

    9/22

    Step6. The first one directly creates the Sales Order & the other Dialog BAPI calls the

    transaction VA01 and waits for the user action like Save or modifying something in the

    Screen.

    Step7.

  • 7/25/2019 Bapi Dialog

    10/22

    Step8. When it is saved the Sales order number is generated.

  • 7/25/2019 Bapi Dialog

    11/22

    ------------------------------------xxxx--------------------xxxx--------------------xxxx------------------

    Posted 20th June 2014 byS Prasad

    View comments

    TECHSAP

    [visit www.marathustech.net for

    classroom or online training or

    contact +91 89708 40880]

    https://plus.google.com/114153916726242002532http://freesapabap.blogspot.in/https://plus.google.com/114153916726242002532http://freesapabap.blogspot.in/
  • 7/25/2019 Bapi Dialog

    12/22

    Sidebar

    Home

    opic !torial"

    #P$ !torial"

    opic %i"e !e"tion" for Inter'iew(

    SAP ABAP Short !e"tion" for written inter'iew

    Need SAP raining(

    %ant to )all an* +, from ABAP Program(

    )alling )alc!lator in ABAP Program

    ,eading program text pool

    How to create a Single !ote (

    http://freesapabap.blogspot.in/http://freesapabap.blogspot.in/p/tutorials.htmlhttp://freesapabap.blogspot.in/p/fpm-tutorials.htmlhttp://freesapabap.blogspot.in/p/topic-wise-ques-ans.htmlhttp://freesapabap.blogspot.in/p/sap-abap-short-questions-for-written.htmlhttp://freesapabap.blogspot.in/p/need-sap-tarining.htmlhttp://freesapabap.blogspot.com/2015/05/want-to-call-any-url-from-abap-program.htmlhttp://freesapabap.blogspot.com/2015/05/calling-calculator-in-abap-program.htmlhttp://freesapabap.blogspot.com/2015/05/step1.htmlhttp://freesapabap.blogspot.com/2015/05/how-to-create-single-quote.htmlhttp://freesapabap.blogspot.in/http://freesapabap.blogspot.in/p/tutorials.htmlhttp://freesapabap.blogspot.in/p/fpm-tutorials.htmlhttp://freesapabap.blogspot.in/p/topic-wise-ques-ans.htmlhttp://freesapabap.blogspot.in/p/sap-abap-short-questions-for-written.htmlhttp://freesapabap.blogspot.in/p/need-sap-tarining.htmlhttp://freesapabap.blogspot.com/2015/05/want-to-call-any-url-from-abap-program.htmlhttp://freesapabap.blogspot.com/2015/05/calling-calculator-in-abap-program.htmlhttp://freesapabap.blogspot.com/2015/05/step1.htmlhttp://freesapabap.blogspot.com/2015/05/how-to-create-single-quote.html
  • 7/25/2019 Bapi Dialog

    13/22

    )on'er"ion/ ,aw to String

    )on'er"ion" 012 / S,IN4 to S,IN4

    )on'er"ion" / S,IN4 to S,IN4

    )on'er"ion" / S,IN4 to S,IN4

    SAP Script Important Standard Program"

    How to !"e +"er Parameter ID (

    How to call $aintenance 5iew Programaticall*(

    How get to 6now SAP78A5A engine i" acti'e or not(

    How to )hec6 Different ang!age" In"talled in SAP S*"tem(

    $axim!m allowed "e""ion" in SAP(

    How to )reate N!mber ,ange 9b:ect ;x- SN,93.Smartfrom / How to deb!g a "martform(

    >1.Smartform / Pa""ing data from dri'er program to Smartform interface

    >>.Smartform/ +"e of )op* %indow in Smartform

    %riting to or ,eading from Application Ser'er B* ABAP )la""e"

    Downloading #ile from SAP Appliciation Ser'er Director*

    +ploading #ile to SAP Appliciation Ser'er Director*

    ,eading Data from SAP Application Ser'er ; x- A>> / #P$ Integrating Search +IBB and i"t +IBB into #P$ 95P Application

    )reating ,ange able *pe in Data Dictionar*

    )on'erting Script 9# data to PD#

    Need to )on'ert Spool ,eE!e"t04enerated Bac6gro!nd 8ob 2 Into PD#

    Need to )on'ert Spool ,eE!e"t09# Script2 Into PD#

    abbed Bloc6 at Selection-"creen

    E,#) with 9!tbo!nd !e!e & Inbo!nd !e!e between two different SAP "*"tem" - 9ne +% per mixed part of the

    !e!e"

    E,#) with 9!tbo!nd !e!e & Inbo!nd !e!e between two different SAP "*"tem" - 9ne +% per !e!e )all

    http://freesapabap.blogspot.com/2015/01/part3-fpm-ovp-application-integrating_20.htmlhttp://freesapabap.blogspot.com/2015/01/part3-fpm-ovp-application-integrating.htmlhttp://freesapabap.blogspot.com/2015/01/part2-fpm-integarting-search-uibb-and.htmlhttp://freesapabap.blogspot.com/2015/01/fpm-integarting-search-uibb-and-list.htmlhttp://freesapabap.blogspot.com/2015/01/creating-range-table-type-in-data.htmlhttp://freesapabap.blogspot.com/2015/01/converting-script-otf-data-to-pdf.htmlhttp://freesapabap.blogspot.com/2015/01/need-to-convert-spool-requestgenerated.htmlhttp://freesapabap.blogspot.com/2015/01/need-to-convert-spool-request-into-pdf.htmlhttp://freesapabap.blogspot.com/2015/01/tabbed-block-at-selection-screen.htmlhttp://freesapabap.blogspot.com/2014/12/qrfc-with-outbound-queue-inbound-queue_55.htmlhttp://freesapabap.blogspot.com/2014/12/qrfc-with-outbound-queue-inbound-queue_55.htmlhttp://freesapabap.blogspot.com/2014/12/qrfc-with-outbound-queue-inbound-queue_56.htmlhttp://freesapabap.blogspot.com/2015/01/part3-fpm-ovp-application-integrating_20.htmlhttp://freesapabap.blogspot.com/2015/01/part3-fpm-ovp-application-integrating.htmlhttp://freesapabap.blogspot.com/2015/01/part2-fpm-integarting-search-uibb-and.htmlhttp://freesapabap.blogspot.com/2015/01/fpm-integarting-search-uibb-and-list.htmlhttp://freesapabap.blogspot.com/2015/01/creating-range-table-type-in-data.htmlhttp://freesapabap.blogspot.com/2015/01/converting-script-otf-data-to-pdf.htmlhttp://freesapabap.blogspot.com/2015/01/need-to-convert-spool-requestgenerated.htmlhttp://freesapabap.blogspot.com/2015/01/need-to-convert-spool-request-into-pdf.htmlhttp://freesapabap.blogspot.com/2015/01/tabbed-block-at-selection-screen.htmlhttp://freesapabap.blogspot.com/2014/12/qrfc-with-outbound-queue-inbound-queue_55.htmlhttp://freesapabap.blogspot.com/2014/12/qrfc-with-outbound-queue-inbound-queue_55.htmlhttp://freesapabap.blogspot.com/2014/12/qrfc-with-outbound-queue-inbound-queue_56.html
  • 7/25/2019 Bapi Dialog

    17/22

    E,#) with 9!tbo!nd !e!e & Inbo!nd !e!e between two different SAP "*"tem" - 9ne +% for $!ltiple +=+= )all"

    %ant to )all an* +, from ABAP Program(-------------------------------------------------------------------------------------------------------------------------------Code:---------------------------------------------------------------------------------------------------------------CALL METHOD cl_gui_frontend_services=>execute EXO!T"#$% docu&ent = ' (t)*#(&e to Docu&ent (++lic(tion = ,.google.co&, ' (t) (nd #(&e of A++lic(tion% +(r(&eter = ' (r(&eter for A++lic(tion% def(ult_director/ = ' Def(ult Director/

    % &(xi&i0ed = ' 1)o 2indo M(xi&i0ed% &ini&i0ed = ' 1)o 2indo Mini&i0ed% s/nc)ronous = ' 2)en ,X,: !uns t)e A++lic(tion in 1/nc)ronous Mode% o+er(tion = ,OE#, ' !eserved: 3er4 f5r 1)ellExecute EXCET"O#1 cntl_error = 6 error_no_gui = 7 4(d_+(r(&eter = 8 file_not_found = 9 +(t)_not_found = file_extension_un;non = < error_execute_f(iled = s/nc)ronous_f(iled = not_su++orted_4/_gui = ? OTHE!1 = 6@." s/-su4rc B> @.% ME11A$E "D s/-&sgid TE s/-&sgt/ #ME! s/-&sgno% 2"TH s/-&sgv6 s/-&sgv7 s/-&sgv8 s/-&sgv9.E#D".

    ---------------------------------------------------------------------------------------------------------------

    1te+6. cl_gui_frontend_services=>execute &et)od c(n 4e used to c(ll (n/ !L. "t c(n4e used to c(ll (n/ e4d/n+roFf+& (++lic(tion fro& t)e +rogr(& (s ever/e4d/n+roFf+& (++lic(tion )(ve (n uniuGe !L.

    http://freesapabap.blogspot.com/2014/12/qrfc-with-outbound-queue-inbound-queue_57.htmlhttp://freesapabap.blogspot.com/2015/05/want-to-call-any-url-from-abap-program.htmlhttp://freesapabap.blogspot.com/2014/12/qrfc-with-outbound-queue-inbound-queue_57.htmlhttp://freesapabap.blogspot.com/2015/05/want-to-call-any-url-from-abap-program.html
  • 7/25/2019 Bapi Dialog

    18/22

    1te+7. Here it c(lls t)e !L.

  • 7/25/2019 Bapi Dialog

    19/22

    1te+8. 1till e c(n o+en (n/ docu&ent 4/ s+ecif/ing t)e (++ro+ri(te execut(4le fileloc(tion of t)e director/ of t)e file (nd +roviding t)e file n(&e.

  • 7/25/2019 Bapi Dialog

    20/22

    1te+9. Here is one ex(&+le )o e c(n o+en ( D file 4/ t)e &et)odcl_gui_frontend_services=>execute.

  • 7/25/2019 Bapi Dialog

    21/22

    -------------------------------------------------------------------------------------------------------------------------------

    Posted 2 days ago byS Prasad

    View comments

    https://plus.google.com/114153916726242002532https://plus.google.com/114153916726242002532
  • 7/25/2019 Bapi Dialog

    22/22

    Loading