BAPI/ BDC in program
Hi All,
I am using a 2 BAPI's and 3 BDC's in a program. I need all these BAPI and BDC's update the tanscations in a single bundled task? that is if any of BAPI or BDC failed the sucessful BAPI/BDC should be rolled back. How can I make it happen? Any sample code will be helpful
All Suggestion will be rewarded.
Hi,
This requirement can make the program a complex one. But you can give a try.
Use BDC session method. At end, check whether all the BAPI's and BDC's are successfull or not, if successful write some code to process all the sessions else don't process all the sessions.
Hope this helps.
Thanks,
Srinivasa
Similar Messages
-
what is the difference between BAPI & BDC ?
Hi
<b>BAPI</b>
BAPI stands for Business API(Application Program Interface).
A BAPI is remotely enabled function module
ie it can be invoked from remote programs like standalone JAVA programs, web interface etc..
You can make your function module remotely enabled in attributes of Function module but
A BAPI are standard SAP function modules provided by SAP for remote access.
Also they are part of Businees Objest Repository(BOR).
BAPI are RFC enabled function modules. the difference between RFc and BAPI are business objects.
You create business objects and those are then registered in your BOR (Business Object Repository)
which can be accessed outside the SAP system by using some other applications (Non-SAP) such as VB or JAVA.
In this case u only specify the business object and its method from external system
in BAPI there is no direct system call. while RFC are direct system call.
Some BAPIs provide basic functions and can be used for most SAP business object types.
These BAPIs should be implemented the same for all business object types.
Standardized BAPIs are easier to use and prevent users having to deal with a number of different BAPIs.
Whenever possible, a standardized BAPI must be used in preference to an individual BAPI.
Check these Links out
http://searchsap.techtarget.com/ateQuestionNResponse/0,289625,sid21_cid558752_tax293481,00.html
http://www.sap-img.com/abap/interview-question-on-bapi-rfc-abap-objects-tables.htm
http://www.sap-img.com/fu033.htm
http://www.sap-img.com/abap/ale-bapi.htm
Refer following SDN threads:
Diff. Between BAPI and RFC
Re: BAPI and RFC
<b>
BDC:</b>
Batch Data Communication (BDC) is the process of transferring data from one SAP System to another SAP system or from a non-SAP system to SAP System.
Features :
BDC is an automatic procedure.
This method is used to transfer large amount of data that is available in electronic medium.
BDC can be used primarily when installing the SAP system and when transferring data from a legacy system (external system).
BDC uses normal transaction codes to transfer data.
Types of BDC :
CLASSICAL BATCH INPUT (Session Method)
CALL TRANSACTION
BATCH INPUT METHOD:
This method is also called as CLASSICAL METHOD.
Features:
Asynchronous processing.
Synchronous Processing in database update.
Transfer data for more than one transaction.
Batch input processing log will be generated.
During processing, no transaction is started until the previous transaction has been written to the database.
CALL TRANSACTION METHOD :
This is another method to transfer data from the legacy system.
Features:
Synchronous processing. The system performs a database commit immediately before and after the CALL TRANSACTION USING statement.
Updating the database can be either synchronous or asynchronous. The program specifies the update type.
Transfer data for a single transaction.
Transfers data for a sequence of dialog screens.
No batch input processing log is generated.
For BDC:
http://myweb.dal.ca/hchinni/sap/bdc_home.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&
http://www.sap-img.com/abap/learning-bdc-programming.htm
http://www.sapdevelopment.co.uk/bdc/bdchome.htm
http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm
http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm
http://www.sap-img.com/abap/learning-bdc-
http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html -
Hi Gurus,
Could any body give me the Exact Diffenece B/n BAPI & BDC
Regards
VijayaHi Vijaya,
A BAPI is a method of a SAP Business Object. BAPI enables SAP and third party applications to interact and integrate
with each other at the Business Object / Process level.
Check this link to know more about BAPI.
http://www.sapgenie.com/abap/bapi/example.htm
http://sappoint.com/abap/
Batch Data Communication (BDC) is the oldest batch interfacing technique that SAP provided since the early versions of R/3. BDC is not a
typical integration tool, in the sense that, it can be only be used for uploading data into R/3 and so it is not bi-directional.
BDC works on the principle of simulating user input for transactional screen, via an ABAP program. Typically the input comes in the form
of a flat file. The ABAP program reads this file and formats the input data screen by screen into an internal table (BDCDATA). The
transaction is then started using this internal table as the input and executed in the background.
In Call Transaction, the transactions are triggered at the time of processing itself and so the ABAP program must do the error handling.
It can also be used for real-time interfaces and custom error handling & logging features. .
To know more about BDC,
check the link.
http://sappoint.com/abap/
Main differences are...
In case of bdc data transfer takes place from flat file into sap system ie the file existing in sap system to sap sytem
where is bapi's r remotly enabled function modules which are assigned to some business objects n used to transfer the data between different business partners who are using different systems other than sap.
not only that...
when you plan to upgrade your system version then bdc willnot support those upgradations where as bapi's will support.
Reward points, if useful.
Regards,
Nitin. -
Error in bdc report program .
Hello Experts ,
I was doing the BDC demo program as explained in tutorial ,
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/309cb157-738d-2910-7691-b74c4ddba3c7&overridelayout=true
but when i run the pgm i get runtime error as
shrt text
type conflict occur when calling fuction module .
Function module was called incorrectely .
here i am pasting the report pgm for bdc ,
<< See below >>
Can anybody suggest how to solve this problem ,
Thks ,
Rushi
Edited by: RUSHI123 on Nov 4, 2009 1:20 PM
Edited by: RUSHI123 on Nov 4, 2009 1:21 PM
Edited by: Rob Burbank on Nov 4, 2009 9:49 AMreport Z98
no standard page heading line-size 255.
include bdcrecx1.
DATA : BEGIN OF ITAB OCCURS 0 ,
ID(4) TYPE C ,
NAME(20) TYPE C ,
END OF ITAB .
start-of-selection.
CALL FUNCTION 'UPLOAD'
EXPORTING
* CODEPAGE = ' '
FILENAME = 'C:\'
FILETYPE = 'ASC '
* ITEM = ' '
* FILEMASK_MASK = ' '
* FILEMASK_TEXT = ' '
* FILETYPE_NO_CHANGE = ' '
* FILEMASK_ALL = ' '
* FILETYPE_NO_SHOW = ' '
* LINE_EXIT = ' '
* USER_FORM = ' '
* USER_PROG = ' '
* SILENT = 'S'
* IMPORTING
* FILESIZE =
* CANCEL =
* ACT_FILENAME =
* ACT_FILETYPE =
TABLES
DATA_TAB = ITAB
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
IF SY-SUBRC <> 0.
WRITE :/ SY-SUBRC .
ENDIF.
perform open_group.
LOOP AT ITAB .
perform bdc_dynpro using 'ZTRNSBDCDEMO' '1000'.
perform bdc_field using 'BDC_CURSOR'
'NAME'.
perform bdc_field using 'BDC_OKCODE'
'=SPOS'.
perform bdc_field using 'ID'
ITAB-ID . "... ' 3'.
perform bdc_field using 'NAME'
ITAB-NAME . " ...'MIRAJ'.
perform bdc_dynpro using 'SAPLSVAR' '0281'.
perform bdc_field using 'BDC_OKCODE'
'=BACKLIST'.
perform bdc_dynpro using 'ZTRNSBDCDEMO' '1000'.
perform bdc_field using 'BDC_OKCODE'
'/EE'.
perform bdc_field using 'BDC_CURSOR'
'NAME'.
perform bdc_transaction using 'Z98DEMO'.
ENDLOOP .
And please use code tags
Edited by: RUSHI123 on Nov 4, 2009 1:41 PM
Edited by: RUSHI123 on Nov 4, 2009 1:44 PM
Edited by: Rob Burbank on Nov 4, 2009 9:49 AM -
BAPI or Conversion Program for Head Office/Branch functionality
We are shifting our Vendors to Head Office/Branch functionality. Our ordering vendor now becomes a Branch. We need to transfer any open items left in the Ordering vendor account, and move them to the new Head Office account.
Has somebody done this in their own company or client? If yes, please advise your methodology, and if any BAPIs or conversion programs were used, please let us know.
Thank you for your help.
CoreHi
Just Check the link below.
http://help.sap.com/saphelp_45b/helpdata/en/5f/1faba54aee11d189740000e8322d00/frameset.htm
Hope it helps.
Regards
Mohamed Mansoor -
Hi All,
I am doing bapi fm upload program, when i run the program it shows the short dump error,
i debug this program, the cursor is not move after tansaction_commit,
it shows the FM: ps_commit. it s not run successfully,
any one help for this error,
( CALL FUNCTION 'BAPI_PS_PRECOMMIT' " CALL FUNCTION MODULE
TABLES
ET_RETURN = lt_ret2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' " CALL FUNCTION MODULE
EXPORTING
WAIT = 'X'.)
Thanks for advance help.
AmudhaHi,
You can delete a project definition using the BAPI "BAPI_BUS2001_DELETE". You must enter the name of the project definition that is to be deleted in "I_PROJECT_DEFINITION". Before the project definition is deleted, the following is checked:
the project definition is deleted in the document tables. If the project has WBS elements, these are also deleted. If the project has other objects such as networks, activities and so on, the BAPI terminates and an error message is displayed. These must be deleted beforehand. The BAPI does not delete these automatically. The project definition is deleted as soon as a LUW (Logical Unit of Work) has been completed with the BAPI BAPI_PS_PRECOMMIT and COMMIT WORK. Only one project or one WBS element from a project can be processed at a time in one LUW. You cannot delete temporary objects. This means that if you create a project in an LUW, you cannot delete it immediately after creating it. You can delete it using this BAPI only after you physically create the project using the BAPIs "BAPI_PS_PRECOMMIT" and "COMMIT WORK".
REgards,
Nandha -
Function module/BAPI or standerd program to define Transport route
Hi All,
I am configuring the TMS configuration through ABAP program .
I am able to configure Domain controller, and able add system to it.
Now I am not able to define Transport route, Can anybody tell me how can I achive this?
Is there any function module/BAPI or standerd program for it?
Thanks,
SwarupHello
To check the BAPIS to related module go to swo1 tcode.
Thank u,
santhosh -
How to debug BDC , Dialog program and Script
Hi all,
Please let me know, how to debug BDC , Dialog program and Script
Thanks&Regards
Devi<b>SCRIPT DEBUGGING</b>
When we want to debug the SAPSCRIPT, we need to first activate the debugger, we have 2 ways to activate the Debugger.
1) Execute the program RSTXDBUG
2) Go to SE71, from the initial screen enter the form name and press Utilities --> Activate Debugger
When we are in the Debug screen,
3.1) F5 will be debug filed by field, that means if a single line is having 5 fields, if we press the F5 this will do field by field,
3.2) F6 will be line by line, that means when we press the F6, it will debug the line and it will go to the next line. F7 also do the same way
3.3) F8 will be very useful when we have any include statement in the SCRIPT, if any include is there and we press the F5 or F6 then this will go that Include (normally SO10 or any transaction text), then if we want line by line debugging then we can press the F5 or F6, or if you want to execute that in a single shot then press the F8, then the debugger will be executed that include and come back to the Script debugging.
Some times in the script, we may right lengthy lines, if we want to debug that whole line, we have an option called Left/Right, this we will find the Debug screen of the script, there is a Push button, we can make use this button to debug.
We can put the breakpoints in the SCRIPT DEBUGGER also, just press the BREAKPOINT Pushbutton from the debugging screen or press EDIT --> Breakpoint
If we want to debug the print program from the SCRIPT DEBUGGER, just press SHIFT+F7 or EDIT --> ABAP Debugging
If we want to see the Windows which are defined in the forms, just press the Go to --> Form --> Windows .if we want to see the pages go to --> Form --> pages. Here we have an option to see the page wise window also go to --> Form --> page Windows
If we want to see the paragraphs which are defined in that script, press go to --> Styles --> paragraphs.
If we want to see the Character formats which are defined in that script, press go to --> Styles --> Character Strings.
If we want to see the Page formats which are defined in that script, press go to --> OTF --> Page.
If we want to see the Elements which are used in the Script, then press go to --> Text Elements --> Form Elements.
If we want to see the commands which are used in the script, press go to --> Commands --> List
Finally, if we want to exit from the SCRIPT DEBUGING, simply press Debugger --> Exit
<b>DEBUG BDC</b>
ust go into debugging mode and do the BDC step by step, when it comes to the Call Transaction line, check the mode which will be 'N'....Now, overwrite this with 'A' and execute the BDC...It will run in All Screens Mode....
As suggested above the MODE 'A' will do the trick as it takes you to all screens.
Normally MODE N will be defaulted as it will be used for background processing,
Here is a simple tip,
This will be the call transaction part of the program,
CALL TRANSACTION 'IW32' USING BDCDATA MODE 'N'
MESSAGES INTO MESSTAB.
I would suggest you to make it like this,
DATA: V_MODE TYPE C VALUE 'N'.
*<In debug mode set V_MODE = 'A' for debugging>
CALL TRANSACTION 'IW32' USING BDCDATA MODE V_MODE
MESSAGES INTO MESSTAB.
This will be very useful because you just need to change the value of the V_MODE at runtime as A for debugging besides it has N which is the default to be used. (i.e. you need not change the code again and again).
This will be very useful when you have to debug some program in QA or PRD servers.
regards,
srinivas
<b>*reward for useful answers*</b> -
Call the BAPI from the program..
Hey guys,
can we call the BAPI from the program..
if yes how can we can show sales orders being loaded..
thanks its urgentNishant,
yes easily you can call bapi from program.
for getting all sales order use:
BAPI_SALESORDER_GETLIST
also am providing a program so that you can see how bapi has to call in program.
CALL FUNCTION 'BAPI_SALESORDER_GETLIST'
EXPORTING
customer_number = lf_customernumber
sales_organization = if_sales_organization
document_date = lf_document_date_from
document_date_to = lf_document_date_to
* PURCHASE_ORDER = IF_PURCH_ORDER
material = lf_matno
IMPORTING
return = ls_return
TABLES
sales_orders = sales_orders.
Am afraid to say you that above solution you get about bapi it is not for showing the list of SO these are for creating SO.
Edited by: Amit Gujargoud on Jul 3, 2008 3:12 PM -
Hi
Can any one tell me the difficulties faced while working with BAPI BDC ALE .
BharathiHI Bharathi,
U have wrongly posted the thread in BI area. If u need any answers then post it in ABAP area.
Bhaskar -
BAPI (Business Application Programming Interface)
BAPI (Business Application Programming Interface) to upload attendances, absences from legacy system to SAP system
can sumbody suggest me the processIf you want to use BAPI´s for this process you should use HR PDC Interphase.
Check SAP Note 647145 for your reference.
If you need additional information let us know. -
BDC upload program for inoftypes 14 and 168
Hi All,
I am uploading IT 14 and 168 through a single BDC program. i am opening the bdc session using
BDC_OPEN_GROUP before bdc recording. my requirement is to upload IT 168 only when uploading
of IT 14 is successful. For this i am using the message table of the first upload(for IT14). if the message
type is 'S'(success) then i am uploading IT168 else i am moving it to an error internal table. Please suugest
wthr this logic is fine. Also where should i call BDC_CLOSE_GROUP. currently i am calling it after the
PERFORM for upload of infotype 168 but it is giving error "unable to open BDC_CLOSE_GROUP".
Can anyone suggest me the solution through some sample code.
i am attaching here my code for your reference.
REPORT ZUSAHR_IN_BN_E_014_168 NO STANDARD PAGE HEADING
LINE-COUNT 65 LINE-SIZE 132.
*=======================================================================
TYPE-POOLS
*=======================================================================
TYPE-POOLS: slis,
truxs.
*=======================================================================
TABLES
*=======================================================================
TABLES: pernr.
*=======================================================================
INFOTYPES
*=======================================================================
INFOTYPES: 0000, "Action
0014, "Recurring payement/deductions
0168. "Insurance plan
*=======================================================================
TYPES
*=======================================================================
TYPES : BEGIN OF t_0014_0168,
num(20) type c, "Number
actcode(1) type c, "action code
lgart LIKE p0014-lgart, "Wage Type
betrg LIKE q0014-betrg, "Amount
betrg(14) type c, "Amount
bplan LIKE p0168-bplan, "Benefit plan
bcovr like p0168-bcovr, "Insurance Option
END OF t_0014_0168,
BEGIN OF t_pernr,
pernr LIKE p0002-pernr, "personnel number
perid like p0002-perid, "SSN
END OF t_pernr,
BEGIN OF errmsg,
pernr LIKE p0014-pernr, "personnel number
messg(85), " message text
END OF errmsg,
BEGIN OF succmsg,
pernr LIKE p0014-pernr, "personnel number
messg(85), " message text
END OF succmsg.
*=======================================================================
INTERNAL TABLES
*=======================================================================
DATA : i_itab TYPE STANDARD TABLE OF t_0014_0168,
i_pernr TYPE STANDARD TABLE OF t_pernr,
i_bdcitab TYPE STANDARD TABLE OF bdcdata ,
i_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll,
i_errmsg TYPE STANDARD TABLE OF errmsg,
i_succmsg TYPE STANDARD TABLE OF succmsg.
*=======================================================================
RANGES
*=======================================================================
*=======================================================================
DATA DECLARATION
*=======================================================================
DATA : messg(85).
*=======================================================================
GLOBAL WORKAREAS
*=======================================================================
DATA : wa_itab TYPE t_0014_0168,
wa_pernr TYPE t_pernr,
wa_bdcitab TYPE bdcdata ,
wa_bdcmsgcoll TYPE bdcmsgcoll,
wa_errmsg TYPE errmsg,
wa_succmsg TYPE succmsg.
*=======================================================================
GLOBAL VARIABLES
*=======================================================================
DATA : g_n1 TYPE sy-dbcnt.
*=======================================================================
GLOBAL CONSTANTS
*=======================================================================
DATA : g_x TYPE c VALUE 'X',
g_asc TYPE char10 VALUE 'ASC',
g_xls(3) TYPE c VALUE 'XLS',
g_f TYPE c VALUE 'F',
g_1 TYPE c VALUE '1',
g_0 TYPE c VALUE '0',
g_u TYPE c VALUE 'U',
g_int(3) TYPE c VALUE 'INT',
g_raw(3) TYPE c VALUE 'RAW',
G_A(1) TYPE C VALUE 'A',
G_C(1) TYPE C VALUE 'C',
G_D(1) TYPE C VALUE 'D'.
*=======================================================================
SELECTION-SCREEN
*=======================================================================
*Block for Additional selection
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_check TYPE char1 DEFAULT 'X', "check box for test run
p_file1 TYPE rlgrap-filename OBLIGATORY, " upload file
p_file2 TYPE rlgrap-filename OBLIGATORY, " succ emp
p_file3 TYPE rlgrap-filename OBLIGATORY. " err emp
SELECTION-SCREEN END OF BLOCK b1.
*=======================================================================
AT SELECTION-SCREEN
*=======================================================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
PERFORM sub_file_intake.
*=======================================================================
START-OF-SELECTION
*=======================================================================
START-OF-SELECTION.
PERFORM sub_data_upload.
PERFORM GET_PERNR_SSN.
*=======================================================================
END-OF-SELECTION
*=======================================================================
END-OF-SELECTION.
*> upload the data using BDC
PERFORM sub_bdc_upload.
*> To display the contents of the input file for test run
IF p_check = space.
PERFORM sub_output.
ELSE.
*> To display in the messages after uploading the input file
PERFORM sub_output_messages.
ENDIF.
*& Form sub_file_intake
F4 on filename to accept file
--> p1 text
<-- p2 text
FORM sub_file_intake .
To provide F4 Functionality for file path
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
CHANGING
file_name = p_file1
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " sub_file_intake
*& Form SUB_DATA_UPLOAD
Upload the input file and perform the checkings.
--> p1 text
<-- p2 text
FORM SUB_DATA_UPLOAD .
*> local variable for filename
DATA : l_file1 TYPE string.
*> assign value for file1.
l_file1 = p_file1.
*> function to upload the input file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file1
filetype = g_asc
has_field_separator = g_x
TABLES
data_tab = i_itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " SUB_DATA_UPLOAD
*& Form sub_output
if program is on test run mode then display records
FORM sub_output .
*> Count the number of employee to be processed
CLEAR g_n1.
DESCRIBE TABLE i_itab LINES g_n1.
IF g_n1 NE 0.
*> if program is in test run mode then display
LOOP AT i_itab INTO wa_itab.
WRITE: / wa_itab-num,
wa_itab-lgart,
wa_itab-betrg,
wa_itab-bplan,
wa_itab-bcovr.
ENDLOOP.
ENDIF.
ENDFORM. " sub_output
*& Form sub_bdc_upload
bdc upload
FORM sub_bdc_upload .
*> Count the number of employee to be processed
CLEAR g_n1.
DESCRIBE TABLE i_itab LINES g_n1.
IF g_n1 NE 0.
PERFORM sub_open_group.
PERFORM sub_bdc_sessions.
PERFORM sub_close_group.
ELSE.
MESSAGE e003(zmsg) WITH text-021.
ENDIF.
ENDFORM. " sub_bdc_upload
*& Form sub_open_group
bdc_open_group
FORM sub_open_group .
*> group name
DATA : c_group LIKE apqi-groupid .
c_group = text-001.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = c_group
holddate = sy-datum
keep = g_x
user = sy-uname
prog = sy-cprog
EXCEPTIONS
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 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.
ENDFORM. " sub_open_group
*& Form sub_close_group
Close the BDC Session
FORM sub_close_group .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 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.
ENDFORM. " sub_close_group
*& Form sub_bdc_sessions
BDC Sessions
FORM sub_bdc_sessions .
*> Local Constants
DATA: l_ctumode LIKE ctu_params-dismode VALUE 'A',
l_cupdate LIKE ctu_params-updmode VALUE 'S',
l_startdate(10) type c,
l_enddate(10) type c,
l_tcode(4) TYPE c VALUE 'PA30',
l_info(2) TYPE c VALUE '14'.
LOOP AT i_itab INTO wa_itab.
perform bdc_dynpro using 'SAPMP50A' '1000'.
IF wa_itab-actcode = G_A.
perform bdc_field using 'BDC_OKCODE'
'=INS'.
ELSEIF wa_itab-actcode = G_D.
perform bdc_field using 'BDC_OKCODE'
'=DEL'.
ELSEIF wa_itab-actcode = G_C.
perform bdc_field using 'BDC_OKCODE'
'=MOD'.
ENDIF.
perform bdc_field using 'RP50G-PERNR' wa_itab-num.
perform bdc_field using 'RP50G-TIMR6'
'X'.
perform bdc_field using 'BDC_CURSOR'
'RP50G-CHOIC'.
perform bdc_field using 'RP50G-CHOIC' l_info.
perform bdc_dynpro using 'MP001400' '2010'.
perform bdc_field using 'BDC_CURSOR'
'Q0014-BETRG'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'P0014-BEGDA'
'03/18/2008'.
perform bdc_field using 'P0014-ENDDA'
'12/31/9999'.
perform bdc_field using 'P0014-LGART' wa_itab-lgart.
perform bdc_field using 'Q0014-BETRG' wa_itab-betrg.
perform bdc_field using 'Q0014-BETRG'
wa_itab-betrg.
' 248'.
perform bdc_field using 'P0014-BETRG' wa_itab-betrg.
perform bdc_field using 'P0014-WAERS'
'USD'.
perform bdc_dynpro using 'MP001400' '2010'.
perform bdc_field using 'BDC_CURSOR'
'P0014-BEGDA'.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.
perform bdc_field using 'P0014-BEGDA'
'03/18/2008'.
perform bdc_field using 'P0014-ENDDA'
'12/31/9999'.
perform bdc_field using 'P0014-LGART' wa_itab-lgart.
perform bdc_field using 'Q0014-BETRG' wa_itab-betrg.
perform bdc_field using 'P0014-BETRG' wa_itab-betrg.
perform bdc_field using 'P0014-WAERS'
'USD'.
*> refresh the message tab
REFRESH i_bdcmsgcoll.
CALL TRANSACTION l_tcode USING i_bdcitab
MODE l_ctumode
UPDATE l_cupdate
MESSAGES INTO i_bdcmsgcoll.
*> refresh the bdc data tab
REFRESH i_bdcitab.
*> store the message for this pernr
PERFORM sub_build_messages.
ENDLOOP.
ENDFORM. " sub_bdc_sessions
Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR wa_bdcitab.
wa_bdcitab-program = program.
wa_bdcitab-dynpro = dynpro.
wa_bdcitab-dynbegin = g_x.
APPEND wa_bdcitab TO i_bdcitab.
ENDFORM. "BDC_DYNPRO
Insert field *
FORM bdc_field USING fnam fval.
IF fval <> space.
CLEAR wa_bdcitab.
wa_bdcitab-fnam = fnam.
wa_bdcitab-fval = fval.
APPEND wa_bdcitab TO i_bdcitab.
ENDIF.
ENDFORM. "BDC_FIELD
*& Form sub_build_messages
Generate the messages
FORM sub_build_messages .
*> Local Constants
DATA : l_s TYPE c VALUE 'S'.
LOOP AT i_bdcmsgcoll INTO wa_bdcmsgcoll.
*> generate the message
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_bdcmsgcoll-msgid
msgnr = wa_bdcmsgcoll-msgnr
msgv1 = wa_bdcmsgcoll-msgv1
msgv2 = wa_bdcmsgcoll-msgv2
msgv3 = wa_bdcmsgcoll-msgv3
msgv4 = wa_bdcmsgcoll-msgv4
IMPORTING
message_text_output = messg
EXCEPTIONS
OTHERS = 1.
IF sy-subrc EQ 0.
*> if message type is 'S' then store in successful table
IF wa_bdcmsgcoll-msgtyp = l_s.
MOVE wa_itab-num TO wa_succmsg-pernr.
MOVE messg TO wa_succmsg-messg.
APPEND wa_succmsg TO i_succmsg.
CLEAR wa_succmsg.
PERFORM BDC_UPLOAD_168.
ELSE.
*> if message type is 'E' then store in error table
MOVE wa_itab-num TO wa_errmsg-pernr.
MOVE messg TO wa_errmsg-messg.
APPEND wa_errmsg TO i_errmsg.
CLEAR wa_errmsg.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " sub_build_messages
*& Form sub_output_messages
text
--> p1 text
<-- p2 text
FORM sub_output_messages .
IF p_check = g_x.
*> clear the count
CLEAR g_n1.
*> count the number of successful employees
DESCRIBE TABLE i_succmsg LINES g_n1.
IF g_n1 <> 0 .
*> download success file
PERFORM sub_succ_file.
*> display the successful employees
WRITE :/ text-002.
LOOP AT i_succmsg INTO wa_succmsg.
WRITE:/ wa_succmsg-pernr, wa_succmsg-messg.
ENDLOOP.
ENDIF.
*> clear the count
CLEAR g_n1.
*> count the number of error employees
DESCRIBE TABLE i_errmsg LINES g_n1.
IF g_n1 <> 0 .
*> download error file
PERFORM sub_err_file.
*> display the error employees
WRITE :/ text-003.
LOOP AT i_errmsg INTO wa_errmsg.
WRITE:/ wa_errmsg-pernr,wa_errmsg-messg.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM. " sub_output_messages
*& Form SUB_SUCC_FILE
text
--> p1 text
<-- p2 text
FORM sub_succ_file .
*> local variable for filename
DATA : l_file1 TYPE string.
*> assign value for file1.
l_file1 = p_file2.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_file1
filetype = g_asc
TABLES
data_tab = i_succmsg
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc EQ 0.
MESSAGE s003(zmsg) WITH text-006.
ENDIF.
ENDFORM. " SUB_SUCC_FILE
*& Form SUB_ERR_FILE
text
--> p1 text
<-- p2 text
FORM sub_err_file .
*> local variable for filename
DATA : l_file1 TYPE string.
*> assign value for file1.
l_file1 = p_file3.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_file1
filetype = g_asc
TABLES
data_tab = i_errmsg
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc EQ 0.
MESSAGE s003(zmsg) WITH text-007.
ENDIF.
ENDFORM. " SUB_ERR_FILE
*& Form GET_PERNR_SSN
text
--> p1 text
<-- p2 text
FORM GET_PERNR_SSN .
data : l_cnt type i.
describe table i_itab lines l_cnt.
if l_cnt ge 0.
SELECT PERNR PERID FROM PA0002 INTO table i_pernr
FOR ALL ENTRIES IN i_itab
WHERE PERID EQ i_itab-num.
IF SY-SUBRC EQ 0.
PERFORM MODIFY_TABLE.
ENDIF.
endif.
ENDFORM. " GET_PERNR_SSN
*& Form MODIFY_TABLE
text
--> p1 text
<-- p2 text
FORM MODIFY_TABLE .
LOOP AT i_itab INTO wa_itab.
READ TABLE i_pernr INTO wa_pernr WITH KEY perid = wa_itab-num.
IF SY-SUBRC EQ 0.
MOVE WA_PERNR-PERNR TO WA_ITAB-NUM.
MODIFY i_itab FROM wa_itab.
ENDIF.
ENDLOOP.
ENDFORM. " MODIFY_TABLE
*& Form BDC_UPLOAD_168
text
--> p1 text
<-- p2 text
FORM BDC_UPLOAD_168 .
PERFORM sub_open_group.
PERFORM sub_bdc_sessions_168.
PERFORM sub_close_group.
ENDFORM. " BDC_UPLOAD_168
*& Form SUB_BDC_SESSIONS_168
text
--> p1 text
<-- p2 text
FORM SUB_BDC_SESSIONS_168 .
DATA: l_ctumode LIKE ctu_params-dismode VALUE 'A',
l_cupdate LIKE ctu_params-updmode VALUE 'S',
l_sdate(10) type c,
l_edate(10) type c,
l_tcode(4) TYPE c VALUE 'PA30',
l_info(3) TYPE c VALUE '168'.
LOOP AT i_itab INTO wa_itab.
perform bdc_dynpro using 'SAPMP50A' '1000'.
IF wa_itab-actcode = G_A.
perform bdc_field using 'BDC_OKCODE'
'=INS'.
ELSEIF wa_itab-actcode = G_D.
perform bdc_field using 'BDC_OKCODE'
'=DEL'.
ELSEIF wa_itab-actcode = G_C.
perform bdc_field using 'BDC_OKCODE'
'=MOD'.
ENDIF.
perform bdc_field using 'RP50G-PERNR' wa_itab-num.
perform bdc_field using 'RP50G-TIMR6'
'X'.
perform bdc_field using 'BDC_CURSOR'
'RP50G-CHOIC'.
perform bdc_field using 'RP50G-CHOIC' l_info.
perform bdc_dynpro using 'MP016800' '2000'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'P0168-BEGDA'
'03/18/2008'.
perform bdc_field using 'P0168-ENDDA'
'12/31/9999'.
perform bdc_field using 'BDC_CURSOR'
'P0168-BCOVR'.
perform bdc_field using 'P0168-BPLAN' wa_itab-bplan.
perform bdc_field using 'P0168-BCOVR' wa_itab-bcovr.
perform bdc_field using 'Q0168-CSTDT'
'03/18/2008'.
perform bdc_field using 'Q0168-EEPER'
'2'.
perform bdc_field using 'P0168-PERIO'
'2'.
perform bdc_dynpro using 'MP016800' '2000'.
perform bdc_field using 'BDC_CURSOR'
'P0168-BEGDA'.
perform bdc_field using 'BDC_OKCODE'
'=UPD'.
perform bdc_field using 'P0168-BEGDA'
'03/18/2008'.
perform bdc_field using 'P0168-ENDDA'
'12/31/9999'.
perform bdc_field using 'P0168-BPLAN' wa_itab-bplan.
perform bdc_field using 'P0168-BCOVR' wa_itab-bcovr.
perform bdc_field using 'Q0168-CSTDT'
'03/18/2008'.
perform bdc_field using 'Q0168-EEPER'
'2'.
*> refresh the message tab
REFRESH i_bdcmsgcoll.
CALL TRANSACTION l_tcode USING i_bdcitab
MODE l_ctumode
UPDATE l_cupdate
MESSAGES INTO i_bdcmsgcoll.
*> refresh the bdc data tab
REFRESH i_bdcitab.
*> store the message for this pernr
PERFORM sub_build_messages_168.
ENDLOOP.
ENDFORM. " SUB_BDC_SESSIONS_168
*& Form SUB_BUILD_MESSAGES_168
text
--> p1 text
<-- p2 text
FORM SUB_BUILD_MESSAGES_168 .
*> Local Constants
DATA : l_s TYPE c VALUE 'S'.
LOOP AT i_bdcmsgcoll INTO wa_bdcmsgcoll.
*> generate the message
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_bdcmsgcoll-msgid
msgnr = wa_bdcmsgcoll-msgnr
msgv1 = wa_bdcmsgcoll-msgv1
msgv2 = wa_bdcmsgcoll-msgv2
msgv3 = wa_bdcmsgcoll-msgv3
msgv4 = wa_bdcmsgcoll-msgv4
IMPORTING
message_text_output = messg
EXCEPTIONS
OTHERS = 1.
IF sy-subrc EQ 0.
*> if message type is 'S' then store in successful table
IF wa_bdcmsgcoll-msgtyp = l_s.
MOVE wa_itab-num TO wa_succmsg-pernr.
MOVE messg TO wa_succmsg-messg.
APPEND wa_succmsg TO i_succmsg.
CLEAR wa_succmsg.
ELSE.
*> if message type is 'E' then store in error table
MOVE wa_itab-num TO wa_errmsg-pernr.
MOVE messg TO wa_errmsg-messg.
APPEND wa_errmsg TO i_errmsg.
CLEAR wa_errmsg.
ENDIF.
ENDIF.
ENDLOOP.
Many thanks in advance!!!!
RupeshFor the IDOC perspective, you can uses CREMAS.
For the mass maintenance you still have XK99 (which also uses CREMAS internally)
True there is NO BAPI
For the BDC and the table control. Well this is not really true.
In batchinput, instead of maintaining the rows by there Number, you should select it at the first position.
OK-CODE /06 will open a selection screen SAPMF02K 2324. The result of the selection screen goes to the first line of the table control.
Of course this works only in BDC
reward points if helpful
Edited by: Alain Bacchi on Jun 18, 2008 8:48 AM -
Bapi Bdc Combination to create customer
Dear all,
I want to create a customer master from external system. What are the standard bapis are there they re not suitable for my requirement. I approach it in the following way. I did a bdc for xd01 and trying to call it from a rfc fm which i prepared. But the data that i passes from this fm is not reaching my bdc program. If any body have a good idea on this please share your idea with me .
1) I created an import parameter in this i created a structure.
2) the same structure i declare with the same name in bdc report(se38).
The code in the fm is in this way
DATA:
t_cust TYPE zcust_table .(this is the structure name in my fm import tab)
EXPORT t_cust TO MEMORY ID 'TABLE'.
SUBMIT ZBDC_CUSTOMER AND RETURN.
3)
DATA :BEGIN OF zcust OCCURS 100 .
INCLUDE STRUCTURE zcust_table.
DATA:END OF ZCUST.
START-OF-SELECTION.
IMPORT t_cust FROM MEMORY ID 'TABLE'.(Thi is my decalration in se38 bdc program.)
when i executed my fm the value that given in fm is not reaching my table which i declared in bdc program.
Regards,
Madhu.Hi,
Populate all the customer details address details and personal details in KNA1 structure.
Populate Company code details in KNB1 structure.
Populate Sales area details in KNVV structure.
Populate dunning data in KNB5 table.
Populate Tax data in KNVI table
In all the structures other than customer number we have to fill all the primary key fields.
Call the SD_CUSTOMER_MAINTAIN_ALL function module to create customer as below.
Create Customer in SAP
CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL'
EXPORTING
i_kna1 = fs_kna1
i_knb1 = fs_knb1
i_knvv = fs_knvv
i_bapiaddr1 = fs_add1
i_bapiaddr2 = fs_add2
pi_postflag = c_true
IMPORTING
e_kunnr = w_kunnr
TABLES
t_xknb5 = t_knb5
t_xknvi = t_knvi
EXCEPTIONS
client_error = 1
kna1_incomplete = 2
knb1_incomplete = 3
knb5_incomplete = 4
knvv_incomplete = 5
kunnr_not_unique = 6
sales_area_not_unique = 7
sales_area_not_valid = 8
insert_update_conflict = 9
number_assignment_error = 10
number_not_in_range = 11
number_range_not_extern = 12
number_range_not_intern = 13
account_group_not_valid = 14
parnr_invalid = 15
bank_address_invalid = 16
tax_data_not_valid = 17
no_authority = 18
company_code_not_unique = 19
dunning_data_not_valid = 20
knb1_reference_invalid = 21
cam_error = 22
OTHERS = 23.
Check sysubrc to know the error .
Please let me know if you need any further details.
Regards
Madhu -
BAPI/ BDC for repartnering of customers in SAP
HI Gurus!
Our MDM goes through a tedious data clean-up process when moving one ship-to partner from one sold-to partner to a new sold-to partner.
They are required to delete the ship-to partner from current sold-to location in all sales organizations. Then partner the sold-to information for each sales organization.
If the ship-to location has a business location ID. Expire the current role and change the operator to the new Sold-to.
So I need to create a program to accomplish the above steps to will improve data integrity and reduce the number of accounts to manage.
So i need to develop a program that can re-partner ship-to locations from one ship-to partner from one sold-to partner to a new sold-to partner. Produce an exception log for any bill-to, payer, customer contact information that has moved but could possibly be incorrect. Create a new role in the Business Location ID.
Using an ALV only allowing user to move records that can be transferred:
u2022 Only allow ship-to transfer for non-marked for deletion records.
u2022 Only allow transfer of ship-to records that are currently partnered to sold-to.
u2022 Do not allow transfer of ship-to records that have different sold-to/bill-to/payer accounts. These will need to be move manually.
u2022 Only allow change if the valid Operator number is the same customer number as the sold-to or the re-partnered sold-to.
So I was just wondering if there is any BAPI that can be used for it or dow e go by BDC or if there is a way to do this in a better manner.
COuld anyone please help me assist in as how to approch the program and go forward please.
Thanks
AaravWhich "partnering" are you talking about?
The whole idea about a BAPI is that you create the transaction and calling context yourself, then you can use the stable interface of the BAPI for the core business logic below it (also remotely, and consistantly beyond release boundaries and the user's influence).
I can understand that Rob and many others are starting to complain about your obscure and unclear questions.
Also, if you close another thread with a "." then I will delete your boss's user ID on SDN... (just joking - please close threads properly. The comment field is not mandatory).
Cheers,
Julius -
Lsmw, bapi, bdc- session, bdc-calltransaction
Hi Experts,
Can you please tell me which method should be used to upload data
1. lsmw
2. bapi
3. bdc-session
4. bdc-calltransaction
which method should be used when?, why?, advantages?
I know the process of doing all this but my question is which method should be followed and when, what will be the advantages and disadvantages.
points will be rewarded.
Thank you.
regards,
Admir.hi,
To decide which method shukld use, we have to understand the differences first.
for 10000 records i will go for session method
Session method.
1) synchronous processing.
2) can tranfer large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until session is processed.
Call transaction.
1) asynchronous processing
2) can transfer small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically
Session method is to populate the data by filling BDC structure
and keep as session to process from SM37 to post in appropriate Transaction.
Call transaction method is to post the data directly into the Transaction from an Executable program.
Session method SAP defined Function modules.
Regards,
Reshma
Maybe you are looking for
-
Keynote and pages icons disappear from dock
Although I tried to fix the icons for Pages and Keynote to the dock by dragging the apps from the application folder to the dock, everytime I restart the computer, the two icons have disappeared. I did repair disk permissions, but it still happpens!
-
Additional Charges for transportation.
We use transportation management for our shipments to and from the DC and within stores. There is a new requirement to add some additional charges to the some of the shipments. I am trying to understand what is the best way to implement this. During
-
Iphoto photo books with extra pages
I am currently making a photo book. As I scroll through my book, there are no blank pages, but in the photo layout across the top of my screen it shows 2 blank pages. What will my final book look like? Will the extra pages across the top be visible i
-
Adobe reader error message - 0.104.
I have recently had to re-install adobe reader 9.5 again and all appeared to be ok. I have just tried to view an online statement and the following message came up " There is a problem with adobe reader. If it is running (which it is) please exit and
-
In which forum can i post direct 2d related issues?
In which forum can i post direct 2d related issues?