Showing posts with label ABAP BDC. Show all posts
Showing posts with label ABAP BDC. Show all posts

Thursday, June 12, 2008

Creating Update Function Modules-BDC

To create a function module, you first need to start the Function Builder. Choose Tools ® ABAP Workbench, Function Builder. For more information about creating function modules, refer to the ABAP Workbench Tools documentation.

To be able to call a function module in an update work process, you must flag it in the Function Builder. When you create the function module, set the Process Type attribute to one of the following values:

* Update with immediate start
Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions can be restarted by the update task in case of errors.
* Update w. imm. start, no restart
Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions may not be restarted by the update task.
* Update with delayed start
Set this option for low priority ("V2") functions that run in their own update transactions. These functions can be restarted by the update task in case of errors.

To display the attributes screen in the Function Builder, choose Goto ® Administration.

Defining the Interface

Function modules that run in the update task have a limited interface:

* Result parameters or exceptions are not allowed since update-task function modules cannot report on their results.
* You must specify input parameters and tables with reference fields or reference structures defined in the ABAP Dictionary.

Calling Update Functions

Synchronous or Asynchronous Processing?

Function modules that run in the update task can run synchronously or asynchronously. You determine this by the form of the commit statement you use:

* COMMIT WORK
This is the standard form, which specifies asynchronous processing. Your program does not wait for the requested functions to finish processing.
*COMMIT WORK AND WAIT
This form specifies synchronous processing. The commit statement waits for the requested functions to finish processing. Control returns to your program after all high priority (V1) function modules have run successfully.
The AND WAIT form is convenient for switching old programs to synchronous processing without having to re-write the code. Functionally, using AND WAIT for update-task updates is just the same as dialog-task updates with PERFORM ON COMMIT.

Parameter Values at Execution
In ABAP, you can call update-task function modules in two different ways. The way you choose determines what parameter values are used when the function module is actually executed. Parameter values can be set either at the time of the CALL FUNCTION statement, or at the time of the COMMIT WORK. The following sections explain.
Calling Update Functions Directly
Adding Update Task Calls to a Subroutine.
The examples in these sections show asynchronous commits with COMMIT WORK.

Calling Update Functions Directly

To call a function module directly, use CALL FUNCTION IN UPDATE TASK directly in your code.

CALL FUNCTION 'FUNCTMOD' IN UPDATE TASK EXPORTING...
The system then logs your request and executes the function module when the next COMMIT WORK statement is reached. The parameter values used to execute the function module are those current at the time of the call.

a = 1.
CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A...
a = 2.
CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A...
a = 3.
COMMIT WORK.

Here, the function module UPD_FM is performed twice in the update task: the first time, with value 1 in PAR, the second time with value 2 in PAR.

Adding Update-Task Calls to a Subroutine

You can also put the CALL FUNCTION IN UPDATE TASK into a subroutine and call the subroutine with:

PERFORM SUBROUT ON COMMIT.
If you choose this method, the subroutine is executed at the commit. Thus the request to run the function in the update task is also logged during commit processing. As a result, the parameter values logged with the request are those current at the time of the commit.

a = 1.
PERFORM F ON COMMIT.
a = 2. PERFORM F ON COMMIT.
a = 3. COMMIT WORK. FORM f.
CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A.
ENDFORM.

In this example, the function module UPD_FM is carried out with the value 3 in PAR. The update task executes the function module only once, despite the two PERFORM ON COMMIT statements. This is because a repeatedly registered one can only be executed once in the case of COMMIT WORK. The subroutine itself, containing the function module call, may not have parameters.

The method described here is not suitable for use inside dialog module code.

Standard Function Module : BDC , Miscellaneous ,File , Calender

(1) BDC

(i)BDC_RECORD_PLAY Run A BDC Session using a Session name and the QID
(ii)BDC_RECORD_FUNCTION_CREATE Create a FM for that BDC recording.
(iii)BDC_RECORD_DATA_CREATE Creating test data for BDC.
(iv)ENQUEUE_BDC_QID
(v)BDC_START_GROUP Calling a BDC QID:
1. First we need to ENQUEUE the BDC using QID using the FM 'ENQUEUE_BDC_QID'
2.To run in background we need to open a JOB and submit the code to the standard program 'RSBDCBTC'

(vi)RSBDCBTC This program will process the BDC session in background.

(vii)PERFORM enqueue_tab IN PROGRAM saplsvix USING 'ZSDT_STK_REQ' v_key c_e c_e. Perform to lock a single entry of table-Note this case is only applicable if there is a maintenance view of the table.

(viii) TH_REMOTE_TRANSACTION Run a transaction on a remote server. Optionally provide BDC data to be used in the transaction

(2) Miscellaneous

(i)HELP_VALUES_GET_NO_DD_NAMEThis is used to display the F4 values for any field.
(ii)Z_MESSAGE_DISPLAY To display Message Logs as an ALV.
(iii)DD_SHLP_CALL_FROM_DYNPThis function is used to provide F4 help using matchcodes.
(iv)WWW_LIST_TO_HTMLAfter running a report, call this function to convert the list output to HTML.
(v)WS_VOLUME_GETGet the label from a frontend device.
(vi)WS_MSG Create a dialog box in which you display an one line message
(vii)WS_EXECUTE execute a program on a windows PC
(viii)WS_EXCEL Start EXCEL on the PC
(ix)WRITE_LIST Useful for writing out the list contents that result from the function LIST_FROM_MEMORY.
(x)UNIT_CONVERSION_SIMPLEconvert weights from one UOM to another.
(xi)TMP_GUI_DIRECTORY_LIST_FILESRetrieve all of the files and subdirectories on the Presentation Server (PC) for a given directory. When a value other than * or *.* is used for the filter, you will not get any directories, unless they match your wildcard filter. For example, if you entered *.png, then only files and directories that end in png will be returned by the function
(xii)TH_USER_LISTShow which users are logged into an app server
(xiii) TH_USER_INFOGive information about the current user (sessions, workstation logged in from, etc)
(xiv) TH_DELETE_USER Logoff a user. Similar results to using SM04.
(xv) TERMINAL_ID_GETReturn the terminal id
(xvi) SXPG_COMMAND_LIST_GET Select a list of external OS command definitions.
(xvii)SXPG_COMMAND_EXECUTECheck a user's authorization to use a command, as in SXPG_COMMAND_CHECK. If the authorization check is successful, then execute the command on the target host system.
(xviii) SXPG_COMMAND_DEFINITION_GETRead the definition of a single external OS command from the R/3 System's database.
(xviv) SXPG_COMMAND_CHECK Check whether the user is authorized to execute the specified command on the target host system with the specified arguments.
(xx)SXPG_CALL_SYSTEM you can check the user's authorization for the specified command and run the command. The command runs on the host system on which the function module is executed. The function module is RFC capable. It can therefore be run on the host system at which a user happens to be active or on another designated host system at which an R/3 server is active.
(xxi)TH_POPUP Display a popup system message on a specific users screen.


(3)File

WS_FILENAME_GET Call File Selector
WS_FILE_DELETE Delete File at the Frontend
UPLOAD_FILES Will load one or more files from app or presentation server
UPLOAD upload a file to the presentation server (PC)

(4)Calender

WEEK_GET_FIRST_DAYFor a given week (YYYYMM format), this function returns the date of the Monday of that week.

(5)System Information

TH_ENVIRONMENT
Get the UNIX environment

Free Download SAP ABAP BDC & LSMW pdf book

Topic Covered in this PDF are :

(1) What is BDC or batch Input.
(2) BDC Function
(3)BDC method
(4) BDC technique used in programs
(5) Exercise -(i) Call Transaction Method (ii) Call by session Method
(6)LSMW

  • SAP data migration with LSMW
  • Exercise
  • Define Source Structure
  • Define target Strucutre
  • Field mapping
  • Specify File : Loaction of Source File

Download Pdf ----> http://www.savefile.com/files/799694

What is SAP ABAP BDC and How you use it?

BC Basis Components-

-ABAP workbench-
-BC Basis Programming interfaces
--Data transfer

During data transfer, data is transferred from an external system into the SAP
R/3 System. •Transfer data from an external system into an R/3 System as it is
installed. •Transfer data regularly from an external system into an R/3 System.

Example: If data for some departments in your company is input using a system
other than the R/3 System, you can still integrate this data in the R/3 System. To do
this, you export the data from the external system and use a data transfer method to
import it into the R/3 System.
Batch input with batch input sessions : Data consistency check with the help of
screen logic.

With the batch input method, an ABAP program reads the external data that is to be
entered in the R/3 System and stores the data in a "batch input session". The
session records the actions that are required to transfer data into the system using
normal SAP transactions.

When the program has generated the session, you can run the session to execute
the SAP transactions in it. You can explicitly start and monitor a session with the
batch input management function (by choosing System ® Services ® Batch input), or
have the session run in the background processing system.

Use the BDC_OPEN_GROUP function module to create a new session. Once you
have created a session, then you can insert batch input data into it with
BDC_INSERT. Use the BDC_INSERT function module to add a transaction to a
batch input session. Use the BDC_CLOSE_GROUP function module to close a
session after you have inserted all of your batch input data into it.

Free Download SAP BDC Presentation

http://www.savefile.com/files/750821

SAP BDC Notes

Q: Our ABAP program is working properly in Foreground. Can I schedule it for background processing on the weekend?
A: SAP standard program RSBDCSUB helps you to schedule the job. Create a variant for RSBDCSUB with the BDC session name.

Q: How can we send a mail to the user intimating him that his report/BDC is completed in background?
A: You can use FUNCTION RS_SEND_MAIL_FOR_SPOOLLIST
If Unix is being used, you may send a report to any internet mail with the following:

REPORT ZSNDMAIL .
DATA: COMND(200) type c.
DATA: RESULT(200) type c occurs 100 with header line.
PARAMETERS: FILE(60) type c lower case default '/sapdata/sd_outbound/testmail.dat'.
PARAMETERS: SUBJECT(60) type c lower case.
PARAMETERS: EMAIL(60) type c lower case.
INITIALIZATION.
TRANSLATE EMAIL TO LOWER CASE.
START-OF-SELECTION.
TRANSLATE EMAIL TO LOWER CASE.
CONCATENATE 'cat' FILE '| elm -s "' subject '"' email into comnd seperated by space.
CALL 'SYSTEM' ID 'COMMAND' FIELD comnd 'TAB' FIELD UNIX_RESULTS-*SYS*.
Loop at Results.
write: /1 results.
endloop
end-of-selection.

Archives