Purpose of lock in session method?
wat is the purpose of lock objects in session method ? when we use lock objects ?
The R/3 System synchronizes simultaneous access of several users to the same data records with a lock mechanism. When interactive transactions are programmed, locks are set and released by calling function modules. These function modules are automatically generated from the definition of lock objects in the ABAP Dictionary.
The tables in which data records should be locked with a lock request are defined in a lock object together with their key fields. When tables are selected, one table (the primary table) is first selected. Further tables (secondary tables) can also be added using foreign key relationships.
http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/7b/f9813712f7434be10000009b38f8cf/content.htm
http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
Regards,
Santosh
Similar Messages
-
Question in BDC session method.
Hi guys,
I am trying to upload BOM using BDC session method.
While doing this, i have learnt the steps by heart. But i do not understrand the logic behind the steps. For example, why do we include this statement
Data: IT-BDC like BDCDATA occurs 0 with headerline.
What if we don't include this statement?
Moderator message: sorry, these forums are not targeted to provide step by step guides to beginners, please search for available information, take courses, etc.
locked by: Thomas Zloch on Sep 10, 2010 1:06 PMHello Dhirendra,
Thanks for immediate reply. I want to understand BDC method conceptually. What exactly happens by performing each step.
I am putting up the BDC i made. I copied some of the code from here and there. It works fine but i don't understand the purpose of BDCDATA,
call transaction 'cs01'
and form bdc_dynpro and form bdc_field.
I am quite new to ABAP. Please don't mind if i ask dumb questions.
I am unable to understand how control flows through the code logic.
report ZBDCFORCS01
no standard page heading line-size 255.
*include bdcrecx1.
DATA: IT_BDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
IT_MSGCOLL LIKE BDCMSGCOLL OCCURS 0.
TYPES TRUXS_T_TEXT_DATA(4096) TYPE C OCCURS 0.
DATA: I_TAB_RAW_DATA TYPE TRUXS_T_TEXT_DATA.
DATA: BEGIN OF ITAB OCCURS 0,
MATNR(18),
WERKS(4),
STLAN(1),
IDNRK(18),
MENGE(20),
END OF ITAB.
SELECTION-SCREEN: BEGIN OF BLOCK b1.
PARAMETERS: CS01FILE TYPE RLGRAP-FILENAME.
SELECTION-SCREEN: END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR CS01FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = CS01FILE
start-of-selection.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
I_TAB_RAW_DATA = I_TAB_RAW_DATA
I_FILENAME = CS01FILE
TABLES
I_TAB_CONVERTED_DATA = ITAB[]
EXCEPTIONS
CONVERSION_FAILED = 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.
*perform open_group.
LOOP AT ITAB.
perform bdc_dynpro using 'SAPLCSDI' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RC29N-STLAN'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RC29N-MATNR'
'1400-500'.
itab-matnr.
perform bdc_field using 'RC29N-WERKS'
'1000'.
itab-werks.
perform bdc_field using 'RC29N-STLAN'
'1'.
itab-stlan.
perform bdc_field using 'RC29N-DATUV'
'10.09.2010'.
perform bdc_dynpro using 'SAPLCSDI' '0110'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RC29K-BMENG'
'1'.
perform bdc_field using 'RC29K-STLST'
'1'.
perform bdc_field using 'BDC_CURSOR'
'RC29K-EXSTL'.
perform bdc_dynpro using 'SAPLCSDI' '0111'.
perform bdc_field using 'BDC_CURSOR'
'RC29K-LABOR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLCSDI' '0140'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-MENGE(02)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RC29P-IDNRK(01)'
'1300-320'.
ITAB-IDNRK.
perform bdc_field using 'RC29P-IDNRK(02)'
'1300-312'.
ITAB-IDNRK.
perform bdc_field using 'RC29P-MENGE(01)'
'2'.
ITAB-MENGE.
perform bdc_field using 'RC29P-MENGE(02)'
'2'.
ITAB-MENGE.
perform bdc_dynpro using 'SAPLCSDI' '0130'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POSNR'.
perform bdc_field using 'RC29P-POSNR'
'0010'.
perform bdc_field using 'RC29P-IDNRK'
'1300-320'.
perform bdc_field using 'RC29P-MENGE'
'2'.
perform bdc_field using 'RC29P-MEINS'
'PC'.
perform bdc_dynpro using 'SAPLCSDI' '0131'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POTX1'.
perform bdc_field using 'RC29P-SANKA'
'X'.
perform bdc_dynpro using 'SAPLCSDI' '0130'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POSNR'.
perform bdc_field using 'RC29P-POSNR'
'0020'.
perform bdc_field using 'RC29P-IDNRK'
'1300-312'.
perform bdc_field using 'RC29P-MENGE'
'2'.
perform bdc_field using 'RC29P-MEINS'
'PC'.
perform bdc_dynpro using 'SAPLCSDI' '0131'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POTX1'.
perform bdc_field using 'RC29P-SANKA'
'X'.
perform bdc_dynpro using 'SAPLCSDI' '0140'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POSNR(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLCSDI' '0140'.
perform bdc_field using 'BDC_CURSOR'
'RC29P-POSNR(01)'.
perform bdc_field using 'BDC_OKCODE'
'=FCBU'.
perform bdc_transaction using 'CS01'.
*perform close_group.
CALL TRANSACTION 'CS01' USING IT_BDC
MODE 'A'
UPDATE 'S'
MESSAGES INTO IT_MSGCOLL.
REFRESH IT_BDC.
ENDLOOP.
FORM BDC_DYNPRO USING PROGRAM_DYNPRO.
CLEAR IT_BDC.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDC.
ENDFORM.
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM.
Edited by: Yayati6260 on Sep 10, 2010 12:29 PM -
BDC Data transfer - Session method...?
Dear All,
How to Transfer data using BDC Session method? - Step-by-step Process.
Regards,
Dharmeshhi,
this will be usefull to u
2.1. Steps for submitting data for Batch Processing
1. Analyze the transactions for which a BDC program.
The user has to determine the sequence of screens in the transactions and the information about all the fields in every screen. To do this the user must run the transaction .
Then select System  Status. This will give the screen number and the module pool associated with this screen of the transaction. These two are the most important fields that the user would need in order to write the BDC program.
2. Use transaction SE38 to write the BDC program. This ABAP/4 program should reads the external data that is to be entered in the SAP System and stores the data in a "batch-input session." A session stores the actions that are required to enter data using normal SAP transactions. This is done by basically using three functions:
BDC_OPEN_GROUP
BDC_INSERT
BDC_CLOSE_GROUP.
3. To create a batch input session, use the function BDC_OPEN_GROUP. This function has the following 5 parameters :
a. CLIENT which is by default set to SY_MANDT. It is the client in which the session is to be processed.
b. GROUP which is the name of the BDC session. This parameter is important because it is with this name that the user will recognize the BDC session in the batch input queue. Using this name process the BDC session.
c. USER which is usually set to SY-UNAME. It is the user name for starting the session in background.
d. KEEP indicates whether the session should be kept or deleted after processing. If then the session is deleted. If X then the session is retained even after it is successfully processed without any errors.
e. HOLDDATE Lock date. The session is locked and may not be processed until after the date that is specified. Default: No lock date, session can be processed immediately. A lock date is optional.
4. Populate the bdcdata table .
The user may define the table as follows:
DATA: BEGIN OF BDCDATA OCCURS 0.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.
This bdcdata structure has the following fields:
PROGRAM
Name of the program.
DYNPRO
Number of the screen. Set this field only in the first record for the screen.
DYNBEGIN
Indicates the first record for the screen. Set this field to X only in the first record for the screen. (Reset to ' ' (blank) for all other records.)
FNAM
Name of a field in the screen. The FNAM field is not case-sensitive.
FVAL
Value for the field named in FNAM.
5. The next step is to submit the BDC session. Use the BDC_INSERT function module to add a transaction to a batch input session. Specify the transaction that is to be started in the call to BDC_INSERT.
BDC_INSERT takes the following parameters:
TCODE
The code of the transaction that is to be run. TCODE is an EXPORTING parameter in the function module.
DYNPROTAB
The BDCDATA structure that contains the data that is to be processed by the transaction. DYNPROTAB is a tables parameter in the function module.
6. The final step is to close the BDC session. Use the BDC_CLOSE_GROUP function module to close a session. Once a session is closed, it can be processed.
7. Running this program will create a batch input session by the name that is specified in the GROUP parameter in the BDC_CREATE_GROUP function call.
8. Transaction SM35 can be used to process the submitted session. This transaction can be used to check the status of all BDC sessions.
2.2. Summary: Creating Batch Input Session:
Open Batch Input group
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = GROUP
USER = USER
KEEP = KEEP.
Fill in the Data for Transaction in an internal table 'BDCDATA'
FORM INSERT_SCREEN USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
FORM INSERT_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM.
Insert Transacton
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'ME21'
TABLES
DYNPROTAB = BDCDATA.
Close Batch Input group
CALL FUNCTION 'BDC_CLOSE_GROUP'.
Finally to process Batch Input Session, first execute the BDC ABAP. This will create
a BDC session. Run transaction 'SM35' & processes the BDC session.
regards,
padma. -
Regarding call transaction and session method???
HI All,
Cud u pls let me know
1. differences between call transaction and session???
2. Is it possible to schedule call transaction in background?? ( all are saying MODE N = background scheduling in call transaction.......but i dont think so)
3. Is it posible to handle multiple transactions in call transaction ? if so,how?
4. Is it posible to handle multiple transactions in session ? if so,how?
5. How can we see the log in session method????Hi ,
Check this documentation.
About Session method
In this method you transfer data from internal table to database table through sessions.
In this method, an ABAP/4 program reads the external data that is to be entered in the SAP System and stores the data in session. A session stores the actions that are required to enter your data using normal SAP transaction i.e., Data is transferred to session which in turn transfers data to database table.
Session is intermediate step between internal table and database table. Data along with its action is stored in session i.e., data for screen fields, to which screen it is passed, the program name behind it, and how the next screen is processed.
When the program has finished generating the session, you can run the session to execute the SAP transactions in it. You can either explicitly start and monitor a session or have the session run in the background processing system.
Unless session is processed, the data is not transferred to database table.
BDC_OPEN_GROUP
You create the session through program by BDC_OPEN_GROUP function.
Parameters to this function are:
User Name: User name
Group: Name of the session
Lock Date: The date on which you want to process the session.
Keep: This parameter is passed as X when you want to retain session after
processing it or to delete it after processing.
BDC_INSERT
This function creates the session & data is transferred to Session.
Parameters to this function are:
Tcode: Transaction Name
Dynprotab: BDC Data
BDC_CLOSE_GROUP
This function closes the BDC Group. No Parameters.
Some additional information for session processing
When the session is generated using the KEEP option within the BDC_OPEN_GROUP, the system always keeps the sessions in the queue, whether it has been processed successfully or not.
However, if the session is processed, you have to delete it manually. When session processing is completed successfully while KEEP option was not set, it will be removed automatically from the session queue. Log is not removed for that session.
If the batch-input session is terminated with errors, then it appears in the list of INCORRECT session and it can be processed again. To correct incorrect session, you can analyze the session. The Analysis function allows to determine which screen and value has produced the error. If you find small errors in data, you can correct them interactively, otherwise you need to modify batch input program, which has generated the session or many times even the data file.
CALL TRANSACTION
About CALL TRANSACTION
A technique similar to SESSION method, while batch input is a two-step procedure, Call Transaction does both steps online, one after the other. In this method, you call a transaction from your program by
Call transaction <tcode> using <BDCTAB>
Mode <A/N/E>
Update <S/A>
Messages into <MSGTAB>.
Parameter 1 is transaction code.
Parameter 2 is name of BDCTAB table.
Parameter 3 here you are specifying mode in which you execute transaction
A is all screen mode. All the screen of transaction are displayed.
N is no screen mode. No screen is displayed when you execute the transaction.
E is error screen. Only those screens are displayed wherein you have error record.
Parameter 4 here you are specifying update type by which database table is updated.
S is for Synchronous update in which if you change data of one table then all the related Tables gets updated. And sy-subrc is returned i.e., sy-subrc is returned for once and all.
A is for Asynchronous update. When you change data of one table, the sy-subrc is returned. And then updating of other affected tables takes place. So if system fails to update other tables, still sy-subrc returned is 0 (i.e., when first table gets updated).
Parameter 5 when you update database table, operation is either successful or unsuccessful or operation is successful with some warning. These messages are stored in internal table, which you specify along with MESSAGE statement. This internal table should be declared like BDCMSGCOLL, a structure available in ABAP/4. It contains the following fields:
1. Tcode: Transaction code
2. Dyname: Batch point module name
3. Dynumb: Batch input Dyn number
4. Msgtyp: Batch input message type (A/E/W/I/S)
5. Msgspra: Batch input Lang, id of message
6. Msgid: Message id
7. MsgvN: Message variables (N = 1 - 4)
For each entry, which is updated in database, table message is available in BDCMSGCOLL. As BDCMSGCOLL is structure, you need to declare a internal table which can contain multiple records (unlike structure).
Steps for CALL TRANSACTION method
1. Internal table for the data (structure similar to your local file)
2. BDCTAB like BDCDATA
3. UPLOAD or WS_UPLOAD function to upload the data from local file to itab. (Considering file is local file)
4. Loop at itab.
Populate BDCTAB table.
Call transaction <tcode> using <BDCTAB>
Mode <A/N/E>
Update <S/A>.
Refresh BDCTAB.
Endloop.
(To populate BDCTAB, You need to transfer each and every field)
The major differences between Session method and Call transaction are as follows:
SESSION METHOD CALL TRANSACTION
1. Data is not updated in database table unless Session is processed. Immediate updation in database table.
2. No sy-subrc is returned. Sy-subrc is returned.
3. Error log is created for error records. Errors need to be handled explicitly
4. Updation in database table is always synchronous Updation in database table can be synchronous Or Asynchronous.
Error Handling in CALL TRANSACTION
When Session Method updates the records in database table, error records are stored in the log file. In Call transaction there is no such log file available and error record is lost unless handled. Usually you need to give report of all the error records i.e., records which are not inserted or updated in the database table. This can be done by the following method:
Steps for the error handling in CALL TRANSACTION
1. Internal table for the data (structure similar to your local file)
2. BDCTAB like BDCDATA
3. Internal table BDCMSG like BDCMSGCOLL
4. Internal table similar to Ist internal table
(Third and fourth steps are for error handling)
5. UPLOAD or WS_UPLOAD function to upload the data from the local file to itab. (Considering file is local file)
6. Loop at itab.
Populate BDCTAB table.
Call transaction <tr.code> using <Bdctab>
Mode <A/N/E>
Update <S/A>
Messages <BDCMSG>.
Perform check.
Refresh BDCTAB.
Endloop.
7 Form check.
IF sy-subrc <> 0. (Call transaction returns the sy-subrc if updating is not successful).
Call function Format_message.
(This function is called to store the message given by system and to display it along with record)
Append itab2.
Display the record and message.
Check this program for session method using multiple transactions.
Have one BDC_OPEN_GROUP, multiple BDC_INSERT s and one BDC_CLOSE_GROUP.
You should have multiple BDC_INSERT s for multiple transactions.
call function BDC_OPENGROUP.
Build BDC data and cal lBDC_INSERT for transaction 1
Build BDC data and cal lBDC_INSERT for transaction 2
Build BDC data and cal lBDC_INSERT for transaction 3
call function BDC_CLOSE_GROUP.
Check out this sample program
REPORT ztest_report
NO STANDARD PAGE HEADING
LINE-SIZE 255
MESSAGE-ID ZRASH.
Internal Table Declarations *
*--Internal Table for Data Uploading.
DATA : BEGIN OF IT_FFCUST OCCURS 0,
KUNNR(10),
BUKRS(4),
KTOKD(4),
ANRED(15),
NAME1(35),
SORTL(10),
STRAS(35),
ORT01(35),
PSTLZ(10),
LAND1(3),
SPRAS(2),
AKONT(10),
END OF IT_FFCUST.
*--Internal Table to Store Error Records.
DATA : BEGIN OF IT_ERRCUST OCCURS 0,
KUNNR(10),
EMSG(255),
END OF IT_ERRCUST.
*--Internal Table to Store Successful Records.
DATA : BEGIN OF IT_SUCCUST OCCURS 0,
KUNNR(10),
SMSG(255),
END OF IT_SUCCUST.
*--Internal Table for Storing the BDC data.
DATA : IT_CUSTBDC LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*--Internal Table for storing the messages.
DATA : IT_CUSTMSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA : V_FLAG1(1) VALUE ' ',
"Flag used for opening session.
V_TLINES LIKE SY-TABIX,
"For storing total records processed.
V_ELINES LIKE SY-TABIX,
"For storing the no of error records.
V_SLINES LIKE SY-TABIX.
"For storing the no of success records.
Selection screen *
SELECTION-SCREEN BEGIN OF BLOCK B1.
PARAMETERS : V_FNAME LIKE RLGRAP-FILENAME,
V_SESNAM LIKE RLGRAP-FILENAME.
SELECTION-SCREEN END OF BLOCK B1.
Start-of-selection *
START-OF-SELECTION.
*-- Form to upload flatfile data into the internal table.
PERFORM FORM_UPLOADFF.
TOP-OF-PAGE *
TOP-OF-PAGE.
WRITE:/ 'Details of the error and success records for the transaction'
ULINE.
SKIP.
End of Selection *
END-OF-SELECTION.
*-- Form to Generate a BDC from the Uploaded Internal table
PERFORM FORM_BDCGENERATE.
*--To write the totals and the session name.
PERFORM FORM_WRITEOP.
*& Form form_uploadff
Form to upload flatfile data into the internal table.
FORM FORM_UPLOADFF .
*--Variable to change the type of the parameter file name.
DATA : LV_FILE TYPE STRING.
LV_FILE = V_FNAME.
*--Function to upload the flat file to the internal table.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = LV_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = IT_FFCUST
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.
*--Deleting the headings from the internal table.
DELETE IT_FFCUST INDEX 1.
*--Getting the total number of records uploaded.
DESCRIBE TABLE IT_FFCUST LINES V_TLINES.
ENDIF.
ENDFORM. " form_uploadff
*& Form Form_bdcgenerate
Form to Generate a BDC from the Uploaded Internal table
FORM FORM_BDCGENERATE .
*--Generating the BDC table for the fields of the internal table.
LOOP AT IT_FFCUST.
PERFORM POPULATEBDC USING :
'X' 'SAPMF02D' '0105',
' ' 'BDC_OKCODE' '/00' ,
' ' 'RF02D-KUNNR' IT_FFCUST-KUNNR,
' ' 'RF02D-BUKRS' IT_FFCUST-BUKRS,
' ' 'RF02D-KTOKD' IT_FFCUST-KTOKD,
'X' 'SAPMF02D' '0110' ,
' ' 'BDC_OKCODE' '/00',
' ' 'KNA1-ANRED' IT_FFCUST-ANRED,
' ' 'KNA1-NAME1' IT_FFCUST-NAME1,
' ' 'KNA1-SORTL' IT_FFCUST-SORTL,
' ' 'KNA1-STRAS' IT_FFCUST-STRAS,
' ' 'KNA1-ORT01' IT_FFCUST-ORT01,
' ' 'KNA1-PSTLZ' IT_FFCUST-PSTLZ,
' ' 'KNA1-LAND1' IT_FFCUST-LAND1,
' ' 'KNA1-SPRAS' IT_FFCUST-SPRAS,
'X' 'SAPMFO2D' '0120',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0125',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0130',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0340',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0360',
' ' 'BDC_OKCODE' '=ENTR',
'X' 'SAPMF02D' '0210',
' ' 'KNB1-AKONT' IT_FFCUST-AKONT,
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0215',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0220',
' ' 'BDC_OKCODE' '/00',
'X' 'SAPMF02D' '0230',
' ' 'BDC_OKCODE' '=UPDA'.
*--Calling the transaction 'fd01'.
CALL TRANSACTION 'FD01' USING IT_CUSTBDC MODE 'N' UPDATE 'S'
MESSAGES INTO IT_CUSTMSG.
IF SY-SUBRC <> 0.
*--Populating the error records internal table.
IT_ERRCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_ERRCUST.
CLEAR IT_ERRCUST.
*--Opening a session if there is an error record.
IF V_FLAG1 = ' '.
PERFORM FORM_OPENSESSION.
V_FLAG1 = 'X'.
ENDIF.
*--Inserting the error records into already open session.
IF V_FLAG1 = 'X'.
PERFORM FORM_INSERT.
ENDIF.
*--Populating the Success records internal table.
ELSE.
IT_SUCCUST-KUNNR = IT_FFCUST-KUNNR.
APPEND IT_SUCCUST.
CLEAR IT_SUCCUST.
ENDIF.
*--Displaying the messages.
IF NOT IT_CUSTMSG[] IS INITIAL.
PERFORM FORM_FORMATMSG.
ENDIF.
*--Clearing the message and bdc tables.
CLEAR : IT_CUSTBDC[],IT_CUSTMSG[].
ENDLOOP.
*--Getting the total no of error records.
DESCRIBE TABLE IT_ERRCUST LINES V_ELINES.
*--Getting the total no of successful records.
DESCRIBE TABLE IT_SUCCUST LINES V_SLINES.
*--Closing the session only if it is open.
IF V_FLAG1 = 'X'.
PERFORM FORM_CLOSESESS.
ENDIF.
ENDFORM. " Form_bdcgenerate
*& Form populatebdc
FOrm to Populate the BDC table.
FORM POPULATEBDC USING VALUE(P_0178)
VALUE(P_0179)
VALUE(P_0180).
IF P_0178 = 'X'.
IT_CUSTBDC-PROGRAM = P_0179.
IT_CUSTBDC-DYNPRO = P_0180.
IT_CUSTBDC-DYNBEGIN = 'X'.
ELSE.
IT_CUSTBDC-FNAM = P_0179.
IT_CUSTBDC-FVAL = P_0180.
ENDIF.
APPEND IT_CUSTBDC.
CLEAR IT_CUSTBDC.
ENDFORM. " populatebdc
*& Form FORM_OPENSESSION
Form to Open a session.
FORM FORM_OPENSESSION .
*--Variable to convert the given session name into reqd type.
DATA : LV_SESNAM(12).
LV_SESNAM = V_SESNAM.
*--Opening a session.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = LV_SESNAM
HOLDDATE = '20040805'
KEEP = 'X'
USER = SY-UNAME
PROG = SY-CPROG
IMPORTING
QID =
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.
WRITE :/ 'Session not open'.
ENDIF.
ENDFORM. " FORM_OPENSESSION
*& Form FORM_INSERT
fORM TO INSERT ERROR RECOED INTO A SESSION.
FORM FORM_INSERT .
*--Inserting the record into session.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'FD01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
DYNPROTAB = IT_CUSTBDC
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
IF SY-SUBRC <> 0.
WRITE :/ 'Unable to insert the record'.
ENDIF.
ENDFORM. " FORM_INSERT
*& Form FORM_CLOSESESS
Form to Close the Open Session.
FORM FORM_CLOSESESS .
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. " FORM_CLOSESESS
*& Form FORM_FORMATMSG
Form to format messages.
FORM FORM_FORMATMSG .
*--Var to store the formatted msg.
DATA : LV_MSG(255).
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = SY-MSGID
LANG = SY-LANGU
NO = SY-MSGNO
V1 = SY-MSGV1
V2 = SY-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = LV_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE :/ LV_MSG.
ENDIF.
ULINE.
ENDFORM. " FORM_FORMATMSG
*& Form form_writeop
To write the totals and the session name.
FORM FORM_WRITEOP .
WRITE :/ 'Total Records Uploaded :',V_TLINES,
/ 'No of Error Records :',V_ELINES,
/ 'No of Success Records :',V_SLINES,
/ 'Name of the Session :',V_SESNAM.
ULINE.
ENDFORM. " form_writeop
Hope this resolves your query.
Reward all the helpful answers.
Regards -
Hi Friends,
In call transaction we can display both updated and error records separately in a report.
Like that in session method i want to capture and display in a separate report both error and updated records.
Please let me know if you have any ideas
Thanks and Regards
V.Raja sekaranhi,
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.
You cannot re-open a session that already exists and has been closed. If you call BDC_OPEN_GROUP with the name of an existing session, then an additional session with the same name is created.
A batch input program may have only one session open at a time. Before opening a session, make sure that any sessions that the program closes any sessions that it previously had opened.
BDC_OPEN_GROUP takes the following EXPORTING parameters:
· CLIENT
Client in which the session is to be processed.
Default: If you don't provide a value for this parameter, the default is the client under which the batch input program runs when the session is created.
· GROUP
Name of the session that is to be created. May be up to 12 characters long.
Default: None. You must specify a session name.
· HOLDDATE
Lock date. The session is locked and may not be processed until after the date that you specify. Only a system administrator with the LOCK authorization for the authorization object Batch Input Authorizations can unlock and run a session before this date.
Format: YYYYMMDD (8 digits).
Default: No lock date, session can be processed immediately. A lock date is optional.
· KEEP
Retain session after successful processing. Set this option to the value X to have a session kept after it has been successfully processed. A session that is kept remains in the input/output queue until an administrator deletes it.
Sessions that contain errors in transactions are kept even if KEEP is not set.
Default: If not set, then sessions that are successfully processed are deleted. Only the batch input log is kept.
· USER
Authorizations user for background processing. This is the user name that is used for checking authorizations if a session is started in background processing. The user must be authorized for all of the transactions and functions that are to be executed in a session. Otherwise, transactions will be terminated with no authorization errors.
The user can be of type dialog or background. Dialog users are normal interactive users in the SAP system. Background users are user master records that are specially defined for providing authorizations for background processing jobs.
check this link
http://help.sap.com/saphelp_nw04/helpdata/en/fa/097126543b11d1898e0000e8322d00/frameset.htm
Regards,
pankaj -
Difference between Session method and Call transaction method
Hi,
Difference between Session method and Call transaction method in BDCHi,
SESSION method:
Is a standard procedure for transferring large amount of data into the R/3 system.
Data consistency is ensured because batch input uses all thje checks conducted on the normal screen.
It is a two step procedure:
1. Progarm: creates batch input session. This session is the data file that includes everything to begin the transaction.
2. Process session: Which then actually transfers the data to database table.
In this method an ABAP/4 program reads the external data that is to be entered in the SAP system and stores the data in a session.
A session stores the actions that are required to enter your data using normal SAP transactions i.e. data is transferred to session which inturn transfers data to database table. Session is an intermediate step between internal table and database table.
Data along with it's actions are stored in session. i.e. data for screen fields, to which screen it is passed, the program name behind it and how next screen is processed.
When the program has finished generating the session, u can run the session to execute the SAP transactions in it.
BDC_OPEN_GROUP
You create the session through program by BDC_OPEN_GROUP function.
1) User Name: User Name.
2) Group : Name of the session
3) Lock Date : The date when you want to process the session.
4) Keep : This parameter is passed as 'X' when you want to retain session even after processing it.
BDC_INSERT
Data is transferred to session by BDC_INSERT.
BDC_CLOSE_GROUP.
With this function the session will be closed.
CALL TRANSACTION method.
Syntax: call transaction <tr code> using <bdctab>
mode <A/N/E>
update <S/A>
messages into <internal table>.
<tr code> : transaction code
<bdctab> : Name of the BDC table
mode: mode in which you execute the transaction.
A : all screen mode ( all the screens of the transaction are displayed )
N : no screen mode ( no screen will be displayed when you execute the transaction )
E : error screen ( only those screens are displayed where in you have error record )
Update type:
S: synchronous update in which if you change data of one table then all the related tables gets updated and SY_SUBRC is returned for once and all.
A: asynchronous update in which if you change data of one table, the sy-subrc is returned and then updation of other affected tables takes place. So if system fails to update other tables still sy-subrc returned is zero.(that is when first table gets updated ).
messages: if you update database table, operation is either successful or unsuccessful. These messages are stored in internal table. This internal table structure is like BDCMSGCOLL.
TCODE: transaction code.
DYNAME: batch input module name.
DYNNUMB: batch input dyn no.
MSGTYP: batch input message type.
MSGSPRA: batch input language id of message.
MSGID: message id.
MSGV1 .MSGV5: message variables
For each entry which is updated in the database table message is available in BDCMSGCOLL.
Reward if useful
Regards
Srinu -
Error message log in session method of ALV report,
In ALV report please let me know:
1) In session method:
where all error messages are stored,I know that error messages are stored in a log file, so please tell me where is it stored.
2)transaction method:
How to handle error messages in transaction methos(for eg if a weight field text box value is negative)Ans for 2nd point.
CALL TRANSACTION c_mb USING i_bdcdata
MODE g_ctumode
UPDATE g_cupdate
MESSAGES INTO i_messtab.
COMMIT WORK.
IF sy-subrc EQ 0. " BDC Executed Successfully
CLEAR wa_messtab.
LOOP AT i_messtab INTO wa_messtab .
IF wa_messtab-msgtyp = 'S' AND
wa_messtab-msgid = 'M7' AND
wa_messtab-msgnr = '060'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_messtab-msgid
msgnr = wa_messtab-msgnr
msgv1 = wa_messtab-msgv1
msgv2 = wa_messtab-msgv2
msgv3 = wa_messtab-msgv3
msgv4 = wa_messtab-msgv4
IMPORTING
message_text_output = l_msg.
APPEND l_msg TO i_sucsess.
CLEAR l_msg.
g_docsuc = 1.
ELSE.
IF wa_messtab-msgtyp = 'E'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_messtab-msgid
msgnr = wa_messtab-msgnr
msgv1 = wa_messtab-msgv1
msgv2 = wa_messtab-msgv2
msgv3 = wa_messtab-msgv3
msgv4 = wa_messtab-msgv4
IMPORTING
message_text_output = l_msg.
g_errflg = 1.
APPEND l_msg TO i_error.
CLEAR: l_msg.
ENDIF. -
Session method and call transaction methos which one is the sap recomonded
hi
PLease give me the answer to these questions.
session method and call transaction methos which one is the sap recomonded why .
2) if we want to maintain BDC program in all the systems.wt to d0Hi Revethi,
Here is the difference between the Session and Call Transaction method.
Session
Session method supports both small amount of data aswell as large amount of data
2) data processing is asynchronus and data updation is synchronus.
3) it process multiple apllication while perfomaning validations.
4) in session method data will be updated in data base only after processing session only.
5) system provide by default logfile for handling error records.
6) it supports both foreground aswell as background process
in bdc we use FM ... bdc_open_group " for creating Session
bdc_insert " adding transaction and bdcdata table for updating database
bdc_close_group " for closing Session
Call Transaction
Call transaction exclusively for small amout of data
2) it supports only one apllication while perfoming validations
3) there is no default logfile, We can explicitly provide logic for creating logfile for handling error records.
we can create logfile by using structure....BDCMSGCOLL
4) it doesn't support background processing.
5) data processing is synchronous and Data updation is Synchronous( default), in
this method also supports daya updation in asynchronus process also.
Syntax:
Call transaction <transaction-name> using BDCDATA
mode <A/N/E> update <L/A/S>
messages into BDCMSGCOLL. -
Error in my BDC SESSION METHOD
Hi,
I was trying work on BDC SESSION METHOD AND MY TCODE IS XK01.
Here is my code can some one tell me where i am doing wrong becoz its not giving the output as I expected. And I am uploading a tab delimeter file.
report ZAN_BDCVENDOR
no standard page heading line-size 255.
include bdcrecx1.
DATA: I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF RECORD OCCURS 0,
LIFNR(016),
BURKS(004),
EKORG(004),
KTOKK(004),
AKONT(010),
FDGRV(010),
WAERS(005),
END OF RECORD.
start-of-selection.
perform open_group.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\VENDOR.TXT'
FILETYPE = 'ASC'
tables
data_tab = RECORD
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT RECORD.
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'USE_ZAV'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
'8765'.
perform bdc_field using 'RF02K-BUKRS'
'1000'.
perform bdc_field using 'RF02K-EKORG'
'1000'.
perform bdc_field using 'RF02K-KTOKK'
'0001'.
perform bdc_field using 'USE_ZAV'
'X'.
perform bdc_dynpro using 'SAPMF02K' '0210'.
perform bdc_field using 'BDC_CURSOR'
'LFB1-FDGRV'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFB1-AKONT'
'160000'.
perform bdc_field using 'LFB1-FDGRV'
'A1'.
perform bdc_dynpro using 'SAPMF02K' '0310'.
perform bdc_field using 'BDC_CURSOR'
'LFM1-WAERS'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFM1-WAERS'
'usd'.
perform bdc_transaction using 'XK01'.
ENDLOOP.
perform close_group.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = 'SESSION1'
HOLDDATE = FILLER8
KEEP = FILLER1
USER = SY-UNAME
RECORD = FILLER1
PROG = SY-CPROG
IMPORTING
QID =
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.
WRITE 'ERROR IN OPEN_GROUP'.
ENDIF.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
dynprotab = I_BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
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.
I appreciateHi,
i guess, the error is due to, u didnt pass the TCODE parameter in BDC_INSERT FM.
Try by passing it...
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = TCODE*
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
dynprotab = I_BDCDATA
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
Hope it works!!
Regards,
Pavan -
Regarding PO creating with condition record Using Session method
Hi All,
I am facing the following problem during po creation using BDC session method.
If there is error in any of the record in the PO upload file and if we jump to next record during batch input session, system changes data of previous correct record.
Example u2013 Consider following data
Matl code Matl Description Qty UoM Price
98652565 Floater08 EPS Insert -with sta 15000 EA 171
60890125 INSERT (PACKAGING) Wellpappe T 14000 EA 52.3
65646353 INSERT CASE PACKAGING, univers 10000 EA 56.9
98725563 Shipper-2nd-NA-Bubble TS.1850 9000 EA 213.4
Consider that record 2 (60890125) contain wrong data. If we skip this record and move to next record 65646353, system executes previous correct record (98652565) and changes net price of that record (here its 171) to 56.9. If record 3 is also wrong, it will capture price from record 4 and will put it for record 1.
If anyone know the solution, Please let me know.
Thanks in Advance.Hi Prasad,
You may not be clearing some workarea in the program while looping or while sending data to screens, clear workareas when required.
If you still face the same issue, try posting the code here, lets see, whats the problem is.
Rgds,
Sripal -
Creation of Material using BDC Session method & global class
Hi
Creation of Material using BDC Session method & global class by using oops.
can anyone plz help me outHi,
it looks like it's not possible to call this BAPI wihtout material number. Here is a quote from BAPI documentation.
When creating material master data, you must transfer the material
number, the material type, and the industry sector to the method. You
must also enter a material description and its language.
Cheers -
Creating Sales order texts while using BDC session method is not working
Hi All,
I have an existing program which creates sales order using BDC session method.( Actual program uses BAPI to create sales order and in case if any error occurs during creation of sales order BDC session is generated so that user can process it later and i am facing issues in this part of code where it uses BDC)
I wanted to modify this BDC sesion to update the sales order text also. I tried recording VA01 for creationg sales order text unfortunatly it is not capturing the data i am entering in the text fields.
Please suggest if there is any way to create sales order using BDC.
Regards
SheebaHi Madhu,
'=TP_CREATE' is the OK code i am getting for creating TEXTS. But the text entered are not captured in BDC.
Part of BDC program generated for cretaing sales order texts.
perform bdc_dynpro using 'SAPMV45A' '4003'.
perform bdc_field using 'BDC_OKCODE'
'=%_GC 128 22'.
perform bdc_field using 'LV70T-SPRAS'
'EN'.
perform bdc_dynpro using 'SAPMV45A' '4003'.
perform bdc_field using 'BDC_OKCODE'
'=TP_CREATE'.
perform bdc_field using 'LV70T-SPRAS'
'EN'.
perform bdc_dynpro using 'SAPMV45A' '4003'.
perform bdc_field using 'BDC_OKCODE'
'=%_GC 128 22'.
perform bdc_field using 'LV70T-SPRAS'
'EN'.
perform bdc_dynpro using 'SAPMV45A' '4003'.
perform bdc_field using 'BDC_OKCODE'
'=TP_CREATE'.
perform bdc_field using 'LV70T-SPRAS'
'EN'.
perform bdc_dynpro using 'SAPMV45A' '4003'.
perform bdc_field using 'BDC_OKCODE'
'/EBACK'.
perform bdc_field using 'LV70T-SPRAS'
'EN'.
perform bdc_dynpro using 'SAPMV45A' '4001'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
Regards,
Sheeba -
Problem in bdc session method for tcode FS00
Hi Experts,
problem in bdc session method, when i run this program no output is shown.
Even it is not calling the transaction.
code as follows.
*& Report Z_GL_MASTER
*& CATEGORY = BDC.
*& DESCRIPTION = UPLOADING G/L MASTER RECORDS.
*& TECHNICAL CONST = FRANCIS REDDY.
*& FUNTIONAL CONST = FICO.
REPORT Z_GL_MASTER.
*& Internal Table
DATA : BEGIN OF IT_UPLOAD OCCURS 0,
SAKNR LIKE GLACCOUNT_SCREEN_KEY-SAKNR, " ACCOUNT NUMBER.
BUKRS LIKE GLACCOUNT_SCREEN_KEY-BUKRS, " COMPANY CODE.
KTOKS LIKE GLACCOUNT_SCREEN_COA-KTOKS, " ACCOUNT GROUP.
XPLACCT LIKE GLACCOUNT_SCREEN_COA-XPLACCT, " P&L STATEMEMENT.
GVTYP LIKE GLACCOUNT_SCREEN_COA-GVTYP, " P&L STATEMENT TYPE.
XBILK LIKE GLACCOUNT_SCREEN_COA-XBILK, " BALANCE SHEET STATEMENT
SHORT LIKE GLACCOUNT_SCREEN_COA-TXT20_ML, " SHORT TEXT.
LONG LIKE GLACCOUNT_SCREEN_COA-TXT50_ML, " LONG TEXT.
WAERS LIKE GLACCOUNT_SCREEN_CCODE-WAERS, " ACCOUNT CURRENCY.
XSALH LIKE GLACCOUNT_SCREEN_CCODE-XSALH, " ONLY BALANCES IN LOCAL CURRENCY.
MITKZ LIKE GLACCOUNT_SCREEN_CCODE-MITKZ, " RECONCILATION ACCOUNT FOR ACCOUNT TYPEGLACCOUNT_SCREEN_CCODE-MITKZ
XOPVW LIKE GLACCOUNT_SCREEN_CCODE-XOPVW, " OPEN ITEM MANAGEMENT.
XKRES LIKE GLACCOUNT_SCREEN_CCODE-XKRES, " LINE ITEM DISPLAY.
ZUAWA LIKE GLACCOUNT_SCREEN_CCODE-ZUAWA, " SORT KEY.
FSTAG LIKE GLACCOUNT_SCREEN_CCODE-FSTAG, " FIELD STATUS GROUP.
XGKON LIKE GLACCOUNT_SCREEN_CCODE-XGKON, " RELAVENT CASH FLOW.
END OF IT_UPLOAD.
*& Internal Table FOR BDC DATA.
DATA : IT_BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE.
*& DATA DECLARATIONS.
DATA : V_FILE LIKE RLGRAP-FILENAME.
*& SELECTION SCREEN.
PARAMETER : P_FILE LIKE V_FILE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM GET_FILENAME.
START-OF-SELECTION.
PERFORM UPLOAD_DATA.
PERFORM BDCDATA_OPEN.
PERFORM BDC_POPULATE.
PERFORM BDC_CLOSE.
*& Form GET_FILENAME
form GET_FILENAME .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE.
endform. " GET_FILENAME
*& Form UPLOAD_DATA
form UPLOAD_DATA .
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'DAT'
TABLES
data_tab = IT_UPLOAD.
endform. " UPLOAD_DATA
*& Form BDCDATA_OPEN
FORM FOR BDC_OPEN_GROUP.
form BDCDATA_OPEN .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = 'GLMASTER'
HOLDDATE = SY-DATUM
KEEP = 'X'
USER = SY-UNAME.
endform. " BDCDATA_OPEN
*& Form BDC_POPULATE
POPULATING BDC DATA .
form BDC_POPULATE .
loop at it_upload.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=ACC_CRE'.
PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_KEY-SAKNR'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_KEY-SAKNR' IT_UPLOAD-SAKNR.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_KEY-BUKRS' IT_UPLOAD-BUKRS.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=2102_GROUP'.
PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_COA-KTOKS'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-KTOKS' IT_UPLOAD-KTOKS.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-XPLACCT' IT_UPLOAD-XPLACCT.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=2102_BS_PL'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-GVTYP' IT_UPLOAD-GVTYP.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-XBILK' IT_UPLOAD-XBILK.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_CURSOR' 'GLACCOUNT_SCREEN_COA-TXT20_ML'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-TXT20_ML' IT_UPLOAD-SHORT.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_COA-TXT50_ML' IT_UPLOAD-LONG.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=TAB02'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-WAERS' IT_UPLOAD-WAERS.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XSALH' IT_UPLOAD-XSALH.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-MITKZ' IT_UPLOAD-MITKZ.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XOPVW' IT_UPLOAD-XOPVW.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XKRES' IT_UPLOAD-XKRES.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-ZUAWA' IT_UPLOAD-ZUAWA.
PERFORM BDC_SUB1 USING 'X' 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.
PERFORM BDC_SUB2 USING 'BDC_OKCODE' '=TAB03'.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-FSTAG' IT_UPLOAD-FSTAG.
PERFORM BDC_SUB2 USING 'GLACCOUNT_SCREEN_CCODE-XGKON' IT_UPLOAD-XGKON.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'FS00'
TABLES
dynprotab = IT_BDCDATA.
endloop.
endform. " BDC_POPULATE
*& Form BDC_CLOSE
FORM FOR CLOSING BDC_GROUP
form BDC_CLOSE .
CALL FUNCTION 'BDC_CLOSE_GROUP'.
endform. " BDC_CLOSE
*& Form BDC_SUB1
FORM FOR BDCDATA.
form BDC_SUB1 USING A B C.
CLEAR IT_BDCDATA.
IT_BDCDATA-DYNBEGIN = A.
IT_BDCDATA-PROGRAM = B.
IT_BDCDATA-DYNPRO = C.
APPEND IT_BDCDATA.
endform. " BDC_SUB1
*& Form BDC_SUB2
text
form BDC_SUB2 USING A B.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = A.
IT_BDCDATA-FVAL = B.
APPEND IT_BDCDATA.
endform. " BDC_SUB2
Points will be rewarded.
Thanks in advance.
Francis.Hi,
Once the program is executed..It will a BDC session..
THen you have to use the transaction SM35..To process the BDC session..
Thanks,
Naren -
Issue in session method --- urgent
Hi,
I developed one bdc which is working fine in call transaction mode when i am trying to run in session method it is giving information message like ' Processing of batch input session completed'.
i am sending my code below.
report ZAAATEST
no standard page heading line-size 255.
DATA: wa_opt TYPE ctu_params.
PARAMETERS : P_GROUP LIKE APQI-GROUPID DEFAULT 'AVANTIMRG10'.
wa_opt-nobinpt = 'X'.
wa_opt-DISMODE = 'A'.
wa_opt-UPDMODE = 'L'.
WA_OPT-RACOMMIT = 'X'.
include bdcrecx1.Hi,
Go to SM35 transaction code.
Click on your session name.
And click on process.
Regards,
Bhanu -
hi all,
i wrote the session method for f-02 transaction,
if voucher number(bkpf-xblnr) found in bkpf i need to skip that voucher number.i need to display error report like (xblnr belnr bldat). and any errors experienced during batch input creation like format errors etc.these errors also i need to disply in error report.
if voucher number(bkpf-xblnr) not found in bkpf i need to insert that voucher number.
if in the flat file 2 records found in bkpf and 2 records not found in bkpf. in sm35 log file it must show 2 records processed and
2 reocrds with errors.
*& Report ZFGLDIOO20 *
PROGRAM NAME : ZFGLDI0020
REQUEST NO : CD1K900572
APLICATION AREA: FI
AUTHOR : SRINIVAS M
DATE : 13-07-2006
DESCRIPTION :This interface will Developement of a Program to read
and Upload the electronic file containig billing refunds information.
*This upload file will generate transactions in the Accounts payble module.
*After the payments have been done an out put file is created containing the cheque
*information to be uploaded on the revenue billing databases.
REPORT HEADER *
REPORT zfgldi0020 NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 65.
====[TABLES]======================================================
TABLES: bkpf, "Accounting Document Header"
bseg, "Accounting Document Segment"
bsec. "One-Time Account Data Document Segment"
====[TYPE-POOLS]======================================================
TYPE-POOLS: slis.
===[INTERNAL TABLES]==================================================
DATA : BEGIN OF it_file_up OCCURS 0,
sgtxt(11),
ls_c2(5),
zuonr(21),
name1(51),
ls_c5(7),
ls_c6(2),
ls_c7(5),
ls_c8(4),
bldat(9),
ls_c10(9),
ls_c11(21),
ls_c12(2),
ls_c13(31),
ls_c14(31),
ls_c15(31),
ls_c16(31),
ls_c17(31),
ls_c18(5),
wrbtr(16),
ls_c20(51),
ls_c21(51),
ls_c22(51),
ls_c23(51),
ls_c24(51),
ls_c25(7),
ls_c26(21),
ls_c27(3),
ls_c28(21),
ls_c29(9),
ls_c30(21),
ls_c31(16),
END OF it_file_up.
DATA : BEGIN OF it_file OCCURS 0,
bldat(10), "Document Date"
blart(2) TYPE c VALUE 'ZD', "Document Type"
bukrs(4) TYPE n VALUE '0100', "Company Code"
budat(10), "Posting Date"
monat(2) TYPE n VALUE '1', " Period"
waers(3) TYPE c VALUE 'ZAR', "Currency"
xblnr(16) TYPE c, " VALUE 'VOUCHER NUMBER', " Reference"
bktxt(25) TYPE c VALUE 'BILLING REFUNDS', "Doc headertext"
bschl(2) TYPE c VALUE '31', "Posting Key"
hkont(7) TYPE n VALUE '490905', "Account"
name1(35) TYPE c, "Name"
stras(35) TYPE c VALUE '66 Jorissen street', "Street"
ort01(35) TYPE c VALUE 'JOHANNESBERG', "City"
pstlz(4) TYPE n VALUE '2001', "Postal Code"
wrbtr(16) , "Amount"
mwskz(2) TYPE c VALUE 'V0', "Tax Code"
zuonr(18) TYPE c, "Assignment"
sgtxt(50) TYPE c, "Text"
bschl1(2) TYPE c VALUE '40', "Posting Key"
hkont1(7) TYPE n VALUE '8701120', "Account"
wrbtr1(16), "Amount"
zuonr1(18) TYPE c, "Assignment"
sgtxt1(50) TYPE c, "Text"
END OF it_file.
DATA : BEGIN OF it_process OCCURS 0,
bldat(10), "Document Date"
blart(2) TYPE c VALUE 'ZD', "Document Type"
bukrs(4) TYPE n VALUE '0100', "Company Code"
budat(10), "Posting Date"
monat(2) TYPE n VALUE '1', " Period"
waers(3) TYPE c VALUE 'ZAR', "Currency"
xblnr(16) TYPE c, " VALUE 'VOUCHER NUMBER', " Reference"
bktxt(25) TYPE c VALUE 'BILLING REFUNDS', "Doc headertext"
bschl(2) TYPE c VALUE '31', "Posting Key"
hkont(7) TYPE n VALUE '490905', "Account"
name1(35) TYPE c, "Name"
stras(35) TYPE c VALUE '66 Jorissen street', "Street"
ort01(35) TYPE c VALUE 'JOHANNESBERG', "City"
pstlz(4) TYPE n VALUE '2001', "Postal Code"
wrbtr(16) , "Amount"
mwskz(2) TYPE c VALUE 'V0', "Tax Code"
zuonr(18) TYPE c, "Assignment"
sgtxt(50) TYPE c, "Text"
bschl1(2) TYPE c VALUE '40', "Posting Key"
hkont1(7) TYPE n VALUE '8701120', "Account"
wrbtr1(16), "Amount"
zuonr1(18) TYPE c, "Assignment"
sgtxt1(50) TYPE c, "Text"
END OF it_process.
*& BDC/Call transaction data.
DATA: BEGIN OF bdcdata OCCURS 0.
INCLUDE STRUCTURE bdcdata.
DATA: END OF bdcdata.
DATA: BEGIN OF it_error OCCURS 0,
xblnr LIKE bkpf-xblnr,
belnr LIKE bkpf-belnr,
bldat LIKE bkpf-bldat,
END OF it_error.
*DATA: it_check LIKE bkpf OCCURS 0 WITH HEADER LINE.
DATA: messtab LIKE bdcmsgcoll OCCURS 100 WITH HEADER LINE.
DATA: lt_fldcat TYPE slis_t_fieldcat_alv,
lt_errorcat TYPE slis_t_fieldcat_alv.
DATA: BEGIN OF err_fld OCCURS 0,
icon(8),
rec_no(6) TYPE n,
messg(100),
END OF err_fld.
===[DATA]=============================================================
DATA: lv_subrc LIKE sy-subrc,
f_session,
f_session_created,
lv_xblnr LIKE bkpf-xblnr,
lv_doc LIKE bkpf-belnr,
lt_files TYPE filetable,
ls_files TYPE file_table,
lv_return TYPE i,
lv_filen TYPE string,
lv_error,
lv_repid LIKE sy-repid.
DATA: lv_bldat(10),
lv_budat(10).
===[STRUCTURES]=======================================================
DATA: ls_fldcat TYPE slis_fieldcat_alv.
*DATA: ls_fldcat1 TYPE slis_t_fieldcat_alv.
DATA: ls_errorcat TYPE slis_fieldcat_alv.
===[SELECTION SCREEN]=================================================
PARAMETERS:
p_file LIKE rlgrap-filename LOWER CASE OBLIGATORY.
SELECTION-SCREEN SKIP.
PARAMETERS:
p_sess LIKE d0100-mapn DEFAULT 'BILLING' OBLIGATORY.
===[AT SELECTION-SCREEN]==============================================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM get_file_name.
===[START-OF-SELECTION]===============================================
START-OF-SELECTION.
*& Upload file into internal table
PERFORM fm_upload_file.
*& Process file
PERFORM fm_process_file.
===[END-OF-SELECTION]=================================================
END-OF-SELECTION.
IF lv_error <> space.
PERFORM output_error_tab.
ENDIF.
SKIP.
*& No data in file
IF it_file_up[] IS INITIAL.
MESSAGE s016(rp) WITH 'No data found in file'.
ENDIF.
*& Build catalog for column headings
PERFORM fm_build_catalog.
*& Displaying output in alv grid
PERFORM fm_alv_grid_display.
*& Build catalog for column headings
PERFORM fm_error_catalog.
*& Displaying output in alv grid
PERFORM fm_error_grid_display.
===[FORMS]============================================================
*& Form fm_process_file
text
FORM fm_process_file.
PERFORM bdc_open_group.
LOOP AT it_process.
SELECT SINGLE * FROM bkpf
WHERE bukrs = '0100'
AND blart = 'ZD'
AND xblnr = it_process-xblnr.
IF sy-subrc = 0.
it_error-xblnr = bkpf-xblnr.
it_error-belnr = bkpf-belnr.
it_error-bldat = bkpf-bldat.
APPEND it_error.
CONTINUE.
ENDIF.
REFRESH bdcdata.
CLEAR bdcdata.
CONCATENATE : it_process-bldat6(2) '.' it_process-bldat4(2) '.'
it_process-bldat+0(4) INTO lv_bldat.
CONCATENATE : it_process-budat6(2) '.' it_process-budat4(2) '.'
it_process-budat+0(4) INTO lv_budat.
PERFORM bdc_dynpro USING 'SAPMF05A' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BKPF-BLDAT'
lv_bldat.
PERFORM bdc_field USING 'BKPF-BLART'
'ZD'.
PERFORM bdc_field USING 'BKPF-BUKRS'
'0100'.
PERFORM bdc_field USING 'BKPF-BUDAT'
lv_budat.
PERFORM bdc_field USING 'BKPF-MONAT'
'1'.
PERFORM bdc_field USING 'BKPF-WAERS'
'ZAR'.
PERFORM bdc_field USING 'BKPF-XBLNR'
it_process-xblnr.
PERFORM bdc_field USING 'BKPF-BKTXT'
'BILLING REFUNDS'.
PERFORM bdc_field USING 'RF05A-NEWBS'
'31'.
PERFORM bdc_field USING 'RF05A-NEWKO'
'490900'.
PERFORM bdc_dynpro USING 'SAPLFCPD' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEC-PSTLZ'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEC-NAME1'
it_process-name1.
PERFORM bdc_field USING 'BSEC-STRAS'
'66 JORISSEN STREET'.
PERFORM bdc_field USING 'BSEC-ORT01'
'JOHANNESBURG'.
PERFORM bdc_field USING 'BSEC-PSTLZ'
'2001'.
PERFORM bdc_field USING 'BSEC-LAND1'
'ZA'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0302'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWKO'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
it_process-wrbtr.
PERFORM bdc_field USING 'BSEG-MWSKZ'
'V0'.
PERFORM bdc_field USING 'BSEG-ZUONR'
it_process-zuonr.
PERFORM bdc_field USING 'BSEG-SGTXT'
it_process-sgtxt.
PERFORM bdc_field USING 'RF05A-NEWBS'
'40'.
PERFORM bdc_field USING 'RF05A-NEWKO'
'8701120'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-SGTXT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BSEG-WRBTR'
it_process-wrbtr.
PERFORM bdc_field USING 'BSEG-ZUONR'
it_process-zuonr.
PERFORM bdc_field USING 'BSEG-SGTXT'
it_process-sgtxt.
PERFORM bdc_field USING 'DKACB-FMORE'
'X'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-KOSTL'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTE'.
PERFORM bdc_field USING 'COBL-KOSTL'
'444615'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BSEG-WRBTR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING 'BSEG-WRBTR'
it_process-wrbtr.
PERFORM bdc_field USING 'BSEG-ZUONR'
it_process-zuonr.
PERFORM bdc_field USING 'BSEG-SGTXT'
it_process-sgtxt.
PERFORM bdc_field USING 'DKACB-FMORE'
'X'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-KOSTL'.
PERFORM bdc_field USING 'BDC_OKCODE'
'ENTE'.
PERFORM bdc_field USING 'COBL-KOSTL'
'21815'.
PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/EESC'.
PERFORM bdc_field USING 'BDC_CURSOR'
'COBL-KOSTL'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0700'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWBS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'RW'.
PERFORM bdc_field USING 'BKPF-XBLNR'
it_process-xblnr.
PERFORM bdc_field USING 'BKPF-BKTXT'
'BILLING REFUNDS'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=NO'.
PERFORM bdc_dynpro USING 'SAPMF05A' '0700'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF05A-NEWBS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'RW'.
PERFORM bdc_field USING 'BKPF-XBLNR'
it_process-xblnr.
PERFORM bdc_field USING 'BKPF-BKTXT'
'BILLING REFUNDS'.
PERFORM bdc_dynpro USING 'SAPLSPO1' '0200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=YES'.
PERFORM bdc_create_session.
ENDLOOP.
PERFORM bdc_close_session.
ENDFORM. "fm_process_file
*& Form bdc_dynpro
Start new screen *
-->PROGRAM text
-->DYNPRO text
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
CLEAR bdcdata.
ENDFORM. "bdc_dynpro
*& Form bdc_field
Insert field *
-->FNAM text
-->FVAL text
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
CLEAR bdcdata.
ENDFORM. "bdc_field
*& Form bdc_create_session
Create session
FORM bdc_create_session.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'F-02'
TABLES
dynprotab = bdcdata
EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 6
OTHERS = 7.
IF sy-subrc <> 0.
lv_subrc = sy-subrc.
MESSAGE i398(00) WITH 'Cannot insert BDC into session' p_sess
'Return code=' lv_subrc.
ENDIF.
ENDFORM. " bdc_create_session
*& Form bdc_close_session
Close session
FORM bdc_close_session.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
lv_subrc = sy-subrc.
MESSAGE i398(00) WITH 'Cannot close session' p_sess
'Return code=' lv_subrc.
ENDIF.
ENDFORM. " bdc_close_session
*& Form fm_build_catalog
text
FORM fm_build_catalog.
ls_fldcat-fieldname = 'BLDAT'.
ls_fldcat-ref_tabname = 'BKPF'.
ls_fldcat-ref_fieldname = 'BLDAT'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'BLART'.
ls_fldcat-ref_tabname = 'BKPF'.
ls_fldcat-ref_fieldname = 'BLART'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'BUKRS'.
ls_fldcat-ref_tabname = 'BKPF'.
ls_fldcat-ref_fieldname = 'BUKRS'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'BUDAT'.
ls_fldcat-ref_tabname = 'BKPF'.
ls_fldcat-ref_fieldname = 'BUDAT'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'MONAT'.
ls_fldcat-ref_tabname = 'BKPF'.
ls_fldcat-ref_fieldname = 'MONAT'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'WAERS'.
ls_fldcat-ref_tabname = 'BKPF'.
ls_fldcat-ref_fieldname = 'WAERS'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'XBLNR'.
ls_fldcat-ref_tabname = 'BKPF'.
ls_fldcat-ref_fieldname = 'XBLNR'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'BKTXT'.
ls_fldcat-ref_tabname = 'BKPF'.
ls_fldcat-ref_fieldname = 'BKTXT'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'BSCHL'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'BSCHL'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'HKONT'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'HKONT'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'NAME1'.
ls_fldcat-ref_tabname = 'BSEC'.
ls_fldcat-ref_fieldname = 'NAME1'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'STRAS'.
ls_fldcat-ref_tabname = 'BSEC'.
ls_fldcat-ref_fieldname = 'STRAS'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'ORT01'.
ls_fldcat-ref_tabname = 'BSEC'.
ls_fldcat-ref_fieldname = 'ORT01'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'PSTLZ'.
ls_fldcat-ref_tabname = 'BSEC'.
ls_fldcat-ref_fieldname = 'PSTLZ'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'WRBTR'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'WRBTR'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'MWSKZ'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'MWSKZ'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'ZUONR'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'ZUONR'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'SGTXT'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'SGTXT'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'BSCHL1'.
ls_fldcat-ref_tabname = 'ZBSEG'.
ls_fldcat-ref_fieldname = 'BSCHL1'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'HKONT1'.
ls_fldcat-ref_tabname = 'ZBSEG'.
ls_fldcat-ref_fieldname = 'HKONT1'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'WRBTR'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'WRBTR'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'ZUONR'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'ZUONR'.
APPEND ls_fldcat TO lt_fldcat.
ls_fldcat-fieldname = 'SGTXT'.
ls_fldcat-ref_tabname = 'BSEG'.
ls_fldcat-ref_fieldname = 'SGTXT'.
APPEND ls_fldcat TO lt_fldcat.
ENDFORM. "fm_build_catalog
*& Form fm_error_catalog
text
FORM fm_error_catalog.
ls_errorcat-fieldname = 'XBLNR'.
ls_errorcat-ref_tabname = 'BKPF'.
ls_errorcat-ref_fieldname = 'XBLNR'.
APPEND ls_errorcat TO lt_errorcat.
ls_errorcat-fieldname = 'BELNR'.
ls_errorcat-ref_tabname = 'BKPF'.
ls_errorcat-ref_fieldname = 'BELNR'.
APPEND ls_errorcat TO lt_errorcat.
ls_errorcat-fieldname = 'BLDAT'.
ls_errorcat-ref_tabname = 'BKPF'.
ls_errorcat-ref_fieldname = 'BLDAT'.
APPEND ls_errorcat TO lt_errorcat.
ENDFORM. "fm_error_catalog
*& Form fm_alv_grid_display
text
FORM fm_alv_grid_display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = lv_repid
it_fieldcat = lt_fldcat
TABLES
t_outtab = it_process.
ENDFORM. "fm_alv_grid_display
*& Form fm_error_grid_display.
text
FORM fm_error_grid_display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = lv_repid
it_fieldcat = lt_errorcat
TABLES
t_outtab = it_error.
ENDFORM. "fm_error_grid_display
*& Form get_file_name
Get file name
FORM get_file_name.
Select file
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select File'
default_extension = 'Text Files (*.TXT)'
file_filter = cl_gui_frontend_services=>filetype_text
initial_directory = 'C:\'
CHANGING
file_table = lt_files
rc = lv_return
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
READ TABLE lt_files INTO ls_files INDEX 1.
p_file = ls_files-filename.
CLEAR lt_files[].
ENDIF.
ENDFORM. " get_file_name
*& Form fm_upload_file
text
FORM fm_upload_file.
lv_filen = p_file.
Upload file
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_filen
has_field_separator = 'X'
CHANGING
data_tab = it_file_up[]
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
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
lv_subrc = sy-subrc.
MESSAGE e398(00) WITH 'Cannot upload file:' p_file
'Return code=' lv_subrc.
ENDIF.
File did not upload or no data in file
IF it_file_up[] IS INITIAL.
STOP.
ENDIF.
LOOP AT it_file_up.
CHECK it_file_up-ls_c2(4) = '9999'.
it_file-bldat = it_file_up-bldat+0(8). "Document Date"
it_file-budat = it_file-bldat. "Posting Date"
it_file-xblnr = it_file_up-sgtxt+0(10).
it_file-name1 = it_file_up-name1+0(35). "Name"
it_file-wrbtr = it_file_up-wrbtr+0(15). "Amount"
it_file-zuonr = it_file_up-zuonr+0(18). "Assignment"
it_file-sgtxt = it_file_up-sgtxt+0(10). "Text"
it_file-xblnr = it_file-xblnr.
it_file-wrbtr1 = it_file-wrbtr.
it_file-zuonr1 = it_file-zuonr.
it_file-sgtxt1 = it_file-sgtxt.
APPEND it_file.
ENDLOOP.
LOOP AT it_file.
CHECK NOT it_file-bldat IS INITIAL.
MOVE-CORRESPONDING it_file TO it_process.
APPEND it_process.
ENDLOOP.
ENDFORM. " fm_upload_file
*& Form bdc_open_group
text
--> p1 text
<-- p2 text
FORM bdc_open_group .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
group = p_sess
keep = 'X'
user = sy-uname
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.
lv_subrc = sy-subrc.
MESSAGE i398(00) WITH 'Cannot open session' p_sess
'Return code=' lv_subrc.
STOP.
ENDIF.
ENDFORM. " bdc_open_group
anybody suggest me any other way to display error report.
and sm35 logfile logic.Hi,
1) if you want to create documents pls use abap rfbibl00 (here's a documentation) or fm BAPI_ACC_DOCUMENT_POST
2) if you want to change header , use bdc to FB02;
to item use FB09
A.
Maybe you are looking for
-
User does not appear in group created from SAP role
Hello -- I have a user that has logged into InfoView successfully with SAP authentication and is showing in the CMC under the "User List." When I view the list of users in the group that was created from the SAP role he was a part of, he is not there
-
How can I get Photoshop to run?
I have a brand new MAC. I installed the latest Photoshop. It said I needed to install Java Runtime. I did. When Java was finished, it said it couldn't be installed. Does anyone know what I'm doing wrong?
-
Hi Why the heck when you open a bunch of files in iPhoto, Photoshop, or whatever, do you get them in random order instead, like in Classic, in their name order? And it's a different order each time. It can be very itching when you want to apply certa
-
Find meta information for media files
Dear all, How can i find the meta information for media file Duration: Bit rate : Media Type: Video Size: Thanx for all.
-
Best way to share notes?
My wife and I both have Iphones and are looking for a program so we can share a shopping list. If either of us add or remove an item from the list, it would be updated accordingly. Can someone suggest such a program? Thanks!