Anda di halaman 1dari 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.

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 ,

ls_schd
lt_schdx
ls_schdx

TYPE bapischdl,
TYPE TABLE OF bapischdlx,
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'. " PAYER


ls_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'.

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

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,

ls_item
lt_itemx
ls_itemx
lt_part
ls_part
lt_schd
ls_schd
lt_schdx
ls_schdx

TYPE bapisditem,
TYPE TABLE OF bapisditmx,
TYPE bapisditmx,
TYPE TABLE OF bapipartnr,
TYPE bapipartnr,
TYPE TABLE OF bapischedule,
TYPE bapischedule,
TYPE TABLE OF bapischedulex,
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'.

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.

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.

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.

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

------------------------------------xxxx--------------------xxxx--------------------xxxx-----------------Posted 20th June 2014 by S Prasad

View comments

TECHSAP

[visit www.marathustech.net for


classroom or online training or
contact +91 89708 40880]

Sidebar

Home

Topic Tutorials

FPM Tutorials

Topic Wise Questions for Interview?

SAP ABAP Short Questions for written interview

Need SAP Training?

Want to Call any URL from ABAP Program?

Calling Calculator in ABAP Program!

Reading program text pool!

How to create a Single Quote ?

Conversion: Raw to String

Conversions (2) : XSTRING to STRING

Conversions : XSTRING to STRING

Conversions : STRING to XSTRING


SAP Script Important Standard Programs!

How to use User Parameter ID ?

How to call Maintenance View Programatically?

How get to know SAP_JAVA engine is active or not?

How to Check Different Languages Installed in SAP System?

Maximum allowed sessions in SAP?

How to Create Number Range Object [Tx- SNRO]

Editable ALV with save functionality uisng OOABAP

Creating a dynamic variant for a report

Running background job by triggering an event

13.Smartfrom : How to debug a smartform?

12.Smartform : Passing data from driver program to Smartform interface

11.Smartform: Use of Copy Window in Smartform

Writing to or Reading from Application Server By ABAP Classes

Downloading File from SAP Appliciation Server Directory

Uploading File to SAP Appliciation Server Directory

Reading Data from SAP Application Server [ Tx- AL11 ]

Writing Data to SAP Application Server [ Tx- AL11 ]

10. Smartform :Designing a template in Smartform

9. Smartform : Designing a table in smartform

8. Smartform : Displaying address on a Smartform Window

7. Smartform : Displaying a logo on a Smartform Window

6.Smartfrom: How to call a Smartform progrmatically that works in development, quality & production?

5.Smartfrom : How to call a Smartform Progrmatically?

4.Smartform- Using Dynamic Text in window

3.Smartform- Using Standard Text in window

2.Smartform- Using Text module in window

1.Smartform - Using a text element in window

Benefits of use of text elements and its translation

Use of SAP OTR [OnlineText Repository] Text

Part4 : FPM OVP Application -Integrating Search UIBB and List UIBB: Displaying POPUP Screen

Part3 : FPM OVP Application -Integrating Search UIBB and List UIBB: Message Display

Part2 : FPM Integrating Search UIBB and List UIBB into FPM OVP Application : Link to action

Part1 : FPM Integrating Search UIBB and List UIBB into FPM OVP Application

Creating Range Table Type in Data Dictionary

Converting Script OTF data to PDF

Need to Convert Spool Request(Generated Background Job ) Into PDF!

Need to Convert Spool Request(OTF Script) Into PDF!

Tabbed Block at Selection-screen

qRFC with Outbound Queue & Inbound Queue between two different SAP systems - One LUW per mixed part of the
Queues

qRFC with Outbound Queue & Inbound Queue between two different SAP systems - One LUW per Queue Call

qRFC with Outbound Queue & Inbound Queue between two different SAP systems - One LUW for Multiple QUEUE Calls

Want to Call any URL from ABAP Program?


-----------------------------------------------------------------------------------------------------------------------------Code:
-------------------------------------------------------------------------------------------------------------CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
* document
=
" Path+Name to Document
application
= 'www.google.com' " Path and Name of Application
* parameter
=
" Parameter for Application
* default_directory
=
" Default Directory
* maximized
=
" Show Window Maximized
* minimized
=
" Show Window Minimized
* synchronous
=
" When 'X': Runs the Application in Synchronous Mode
* operation
= 'OPEN' " Reserved: Verb fr ShellExecute
EXCEPTIONS
cntl_error
=1
error_no_gui
=2
bad_parameter
=3
file_not_found
=4
path_not_found
=5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed
=8
not_supported_by_gui = 9
OTHERS
= 10.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
-------------------------------------------------------------------------------------------------------------Step1. cl_gui_frontend_services=>execute method can be used to call any URL. It can
be used to call any webdynpro/fpm application from the program as every
webdynpro/fpm application have an uniuqe URL.

Step2. Here it calls the URL.

Step3. Still we can open any document by specifying the appropriate executable file,
location of the directory of the file and providing the file name.

Step4. Here is one example how we can open a PDF file by the method
cl_gui_frontend_services=>execute.

-----------------------------------------------------------------------------------------------------------------------------Posted 2 days ago by S Prasad

View comments

Loading

Anda mungkin juga menyukai