BDC Code for Loan to Employees
Dear Friends,
I have to write a BDC where I have to debit the G/L of Empoyee Loan and credit individual employee accounts.
If you have a similar BDC code available with you please share the same with me.
Regards,
Alok.
hi
First go to tcode SHDB, there select new recording,give a name for the recording and then give the tcode for which u would want to do recording. Now, enter all the values in the tcode completely and then save it.
Now, come back to shdb,..select ur recording and say create a program tab. Select option from the recording aand then save the program..save the program.
Now, upload the flat file from PC using GUI_upload for txt file and ALSM_EXCEL_TO_INTERNAL_TABLE..
Now, pass the internal table values to the perform statements or subroutines and put them in a loop.
Regards,
Vishwa.
Similar Messages
-
Hi,
Can anybody please tell the BDC CODE FOR A PUSH BUTTON.
THANKS IN ADVANCEwhich program? which pushbutton?
-
Hi all,
Can anyone of you provide me complete BDC code for Transaction XD01.
An early reply will be highly appreciated and would be rewarded.
Regards,
NeerajHi Prakash
hope this code will help you.
ABAP BDC SAMPLE CODE XD01
Table/Structure declarations. *
TABLES : KNA1. "Customer master
Constants declarations. *
CONSTANTS : C_MODE VALUE 'A',
C_UPDATE VALUE 'S',
C_X VALUE 'X',
C_SESS TYPE APQI-GROUPID VALUE 'ZCUSTOMER', "Session Name
C_XD01 LIKE TSTC-TCODE VALUE 'XD01'.
Variable declarations. *
DATA : V_FNAME(15) VALUE SPACE, " Name of file to be created
V_FAILREC TYPE I, " No of failed records
V_MSG(255), " Message Text
V_ERRREC TYPE I, " No of failed records
V_LINES TYPE I, " No of records
V_BANKS(15), " Table column BANKS
V_BANKL(15), " Table column BANKL
V_BANKN(15), " Table column BANKN
V_TIDX(2) TYPE N. " Table row index
*-- FLAG DECLARATIONS
DATA : FG_DATA_EXIST VALUE 'X', " Check for data
FG_SESSION_OPEN VALUE ' '. " Check for Session Open
*-- MACRO DEFINITIONS
*-- Macro for BANKS
DEFINE BANKS.
CLEAR V_BANKS.
CONCATENATE 'KNBK-BANKS(' &1 ')' INTO V_BANKS.
CONDENSE V_BANKS.
END-OF-DEFINITION.
*-- Macro for BANKL
DEFINE BANKL.
CLEAR V_BANKL.
CONCATENATE 'KNBK-BANKL(' &1 ')' INTO V_BANKL.
CONDENSE V_BANKL.
END-OF-DEFINITION.
*-- Macro for BANKN
DEFINE BANKN.
CLEAR V_BANKN.
CONCATENATE 'KNBK-BANKN(' &1 ')' INTO V_BANKN.
CONDENSE V_BANKN.
END-OF-DEFINITION.
Structures / Internal table declarations *
*-- Structure to hold BDC data
TYPES : BEGIN OF T_BDCTABLE.
INCLUDE STRUCTURE BDCDATA.
TYPES END OF T_BDCTABLE.
*-- Structure to trap BDC messages
TYPES : BEGIN OF T_MSG.
INCLUDE STRUCTURE BDCMSGCOLL.
TYPES : END OF T_MSG.
*-- Structure to trap ERROR messages
TYPES : BEGIN OF T_ERR_MSG,
MESSAGE(255),
END OF T_ERR_MSG.
*--Internal table to store flat file data
DATA : BEGIN OF IT_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
KTOKD LIKE T077D-KTOKD,
NAME1 LIKE KNA1-NAME1,
SORTL LIKE KNA1-SORTL,
ORT01 LIKE KNA1-ORT01,
PSTLZ LIKE KNA1-PSTLZ,
LAND1 LIKE KNA1-LAND1,
SPRAS LIKE KNA1-SPRAS,
LZONE LIKE KNA1-LZONE,
END OF IT_KNA1.
*--Internal table to store bank details
DATA : BEGIN OF IT_BANK OCCURS 0,
BANKS LIKE KNBK-BANKS,
BANKL LIKE KNBK-BANKL,
BANKN LIKE KNBK-BANKN,
END OF IT_BANK.
*-- Internal table to hold BDC data
DATA: IT_BDCDATA TYPE STANDARD TABLE OF T_BDCTABLE WITH HEADER LINE,
*-- Internal Table to store ALL messages
IT_MSG TYPE STANDARD TABLE OF T_MSG WITH HEADER LINE,
*-- Internal Table to store error messages
IT_ERR_MSG TYPE STANDARD TABLE OF T_ERR_MSG WITH HEADER LINE.
Selection Screen. *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FLNAME(15) OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : R_LIST RADIOBUTTON GROUP GRP1.
SELECTION-SCREEN COMMENT 5(20) TEXT-003.
PARAMETERS : R_SESS RADIOBUTTON GROUP GRP1.
SELECTION-SCREEN COMMENT 30(20) TEXT-004.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
Event:Initialization *
INITIALIZATION.
AT Selection Screen. *
AT SELECTION-SCREEN.
Event: Start-of-Selection *
START-OF-SELECTION.
V_FNAME = P_FLNAME.
PERFORM GET_DATA.
PERFORM GET_BANKDATA.
PERFORM GENERATE_DATASET.
Event: End-of-Selection *
END-OF-SELECTION.
IF FG_DATA_EXIST = ' '.
MESSAGE I010 WITH TEXT-009.
EXIT.
ENDIF.
PERFORM GENERATE_BDCDATA.
PERFORM DISPLAY_ERR_RECS.
Event: top-of-page
TOP-OF-PAGE.
FORM DEFINITIONS *
*& Form get_data
Subroutine to get the data from mard
--> p1 text
<-- p2 text
FORM GET_DATA.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = 'C:\XD01.TXT'
FILETYPE = 'DAT'
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 = IT_KNA1
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF IT_KNA1[] IS INITIAL.
FG_DATA_EXIST = ' '.
ENDIF.
ENDFORM. " get_data
*& Form GENERATE_DATASET
text
--> p1 text
<-- p2 text
FORM GENERATE_DATASET.
MESSAGE I010 WITH 'OPENING FILE IN APPLICATION SERVER'.
**--Creating a data set in application server
OPEN DATASET V_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
**---Transfering data from internal table to dataset
MESSAGE I010 WITH 'TRANSFERING DATA FROM INETERAL TABLE TO THE FILE'.
LOOP AT IT_KNA1.
TRANSFER IT_KNA1 TO V_FNAME.
ENDLOOP.
**--Closing the dataset
MESSAGE I010 WITH 'CLOSING THE FILE'.
CLOSE DATASET V_FNAME.
ENDFORM. " GENERATE_DATASET
*& Form BDC_DYNPRO
text
-->P_0467 text
-->P_0468 text
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.
*& Form BDC_FIELD
text
-->P_0472 text
-->P_0473 text
FORM BDC_FIELD USING FNAM FVAL.
IF NOT FVAL IS INITIAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
ENDIF.
ENDFORM.
*& Form GENERATE_BDCDATA
text
--> p1 text
<-- p2 text
FORM GENERATE_BDCDATA.
REFRESH IT_KNA1.
Opening dataset for reading
OPEN DATASET V_FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
Reading the file from application server
DO.
CLEAR: IT_KNA1,IT_BDCDATA.
REFRESH IT_BDCDATA.
READ DATASET V_FNAME INTO IT_KNA1.
IF SY-SUBRC <> 0.
EXIT.
ELSE.
Populate BDC Data for Initial Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0100',
BDC_FIELD USING 'BDC_CURSOR' 'RF02D-KUNNR',
BDC_FIELD USING 'BDC_OKCODE' '/00',
BDC_FIELD USING 'RF02D-KUNNR' IT_KNA1-KUNNR,
BDC_FIELD USING 'RF02D-KTOKD' IT_KNA1-KTOKD.
Populate BDC Data for Second Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0110',
BDC_FIELD USING 'BDC_CURSOR' 'KNA1-NAME1',
BDC_FIELD USING 'BDC_OKCODE' '/00',
BDC_FIELD USING 'KNA1-NAME1' IT_KNA1-NAME1,
BDC_FIELD USING 'KNA1-SORTL' IT_KNA1-SORTL,
BDC_FIELD USING 'KNA1-ORT01' IT_KNA1-ORT01,
BDC_FIELD USING 'KNA1-PSTLZ' IT_KNA1-PSTLZ,
BDC_FIELD USING 'KNA1-LAND1' IT_KNA1-LAND1,
BDC_FIELD USING 'KNA1-SPRAS' IT_KNA1-SPRAS.
Populate BDC Data for Third Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0120',
BDC_FIELD USING 'BDC_CURSOR' 'KNA1-LZONE',
BDC_FIELD USING 'BDC_OKCODE' '/00',
BDC_FIELD USING 'KNA1-LZONE' IT_KNA1-LZONE.
Populate BDC Data for Fourth Screen
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0125',
BDC_FIELD USING 'BDC_CURSOR' 'KNA1-NIELS',
BDC_FIELD USING 'BDC_OKCODE' '/00'.
Populate BDC Data for Table control for bank details.
V_TIDX = '01'.
LOOP AT IT_BANK.
BANKS V_TIDX.
BANKL V_TIDX.
BANKN V_TIDX.
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0130',
BDC_FIELD USING 'BDC_CURSOR' V_BANKN,
BDC_FIELD USING 'BDC_OKCODE' '=ENTR',
BDC_FIELD USING V_BANKS IT_BANK-BANKS,
BDC_FIELD USING V_BANKL IT_BANK-BANKL,
BDC_FIELD USING V_BANKN IT_BANK-BANKN.
V_TIDX = V_TIDX + 1.
ENDLOOP.
PERFORM : BDC_DYNPRO USING 'SAPMF02D' '0130',
BDC_FIELD USING 'BDC_CURSOR' V_BANKS,
BDC_FIELD USING 'BDC_OKCODE' '=UPDA'.
CALL TRANSACTION C_XD01 USING IT_BDCDATA
MODE C_MODE
UPDATE C_UPDATE
MESSAGES INTO IT_MSG.
IF SY-SUBRC <> 0.
*--In case of error list display
IF R_LIST = C_X.
V_ERRREC = V_ERRREC + 1.
PERFORM FORMAT_MESSAGE.
IT_ERR_MSG-MESSAGE = V_MSG.
APPEND IT_ERR_MSG.
CLEAR : V_MSG,IT_ERR_MSG.
ENDIF.
*--In case of session log
IF R_SESS = C_X.
*-- In case of transaction fails.
IF FG_SESSION_OPEN = ' '.
FG_SESSION_OPEN = C_X.
PERFORM BDC_OPEN_GROUP.
ENDIF. " IF FG_SESSION_OPEN = ' '.
*-- Insert BDC Data..
PERFORM BDC_INSERT_DATA.
ENDIF. " IF R_SESS = C_X.
ENDIF. " IF SY-SUBRC <> 0.
ENDIF. " IF SY-SUBRC <> 0.
ENDDO.
Closing the dataset
CLOSE DATASET V_FNAME.
*-- Close the session if opened
IF FG_SESSION_OPEN = C_X.
PERFORM BDC_CLOSE_GROUP.
CALL TRANSACTION 'SM35'.
ENDIF.
ENDFORM. " GENERATE_BDCDATA
*& Form BDC_OPEN_GROUP
text
--> p1 text
<-- p2 text
FORM BDC_OPEN_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = C_SESS
HOLDDATE = FILLER8
KEEP = C_X
USER = SY-UNAME
RECORD = FILLER1
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " BDC_OPEN_GROUP
*& Form BDC_INSERT_DATA
text
--> p1 text
<-- p2 text
FORM BDC_INSERT_DATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = C_XD01
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
TABLES
DYNPROTAB = IT_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.
ENDFORM. " BDC_INSERT_DATA
*& Form BDC_CLOSE_GROUP
text
--> p1 text
<-- p2 text
FORM BDC_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. " BDC_CLOSE_GROUP
*& Form FORMAT_MESSAGE
text
--> p1 text
<-- p2 text
FORM FORMAT_MESSAGE.
CLEAR V_LINES.
DESCRIBE TABLE IT_MSG LINES V_LINES.
READ TABLE IT_MSG INDEX V_LINES.
CLEAR V_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = IT_MSG-MSGID
LANG = IT_MSG-MSGSPRA
NO = IT_MSG-MSGNR
V1 = IT_MSG-MSGV1
V2 = IT_MSG-MSGV2
V3 = IT_MSG-MSGV3
V4 = IT_MSG-MSGV4
IMPORTING
MSG = V_MSG
EXCEPTIONS
NOT_FOUND = 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. " FORMAT_MESSAGE
*& Form DISPLAY_ERR_RECS
text
--> p1 text
<-- p2 text
FORM DISPLAY_ERR_RECS.
LOOP AT IT_ERR_MSG.
WRITE: / IT_ERR_MSG-MESSAGE.
ENDLOOP.
ENDFORM. " DISPLAY_ERR_RECS
*& Form GET_BANKDATA
text
--> p1 text
<-- p2 text
FORM GET_BANKDATA.
IT_BANK-BANKS = 'AD'.
IT_BANK-BANKL = '1000'.
IT_BANK-BANKN = 'S.B A/C'.
APPEND IT_BANK.
IT_BANK-BANKS = 'AD'.
IT_BANK-BANKL = 'CITY'.
IT_BANK-BANKN = 'CURR. A/C'.
APPEND IT_BANK.
IT_BANK-BANKS = 'AD'.
IT_BANK-BANKL = 'H001'.
IT_BANK-BANKN = 'S.B A/C'.
APPEND IT_BANK.
reward if help. -
BDC code for MB01 Application(Multiple Line Items)
Hi,
Can anybody please send me the BDC CODE for MB01 Application(for Multiple Line items).
Very urgent.
Thanks And Regards,
AjayInstead of BDC you can use following BAPI.
see the following ex:
BAPI TO Upload Inventory Data
GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order
02 - MB31 - Goods Receipts for Prod Order
03 - MB1A - Goods Issue
04 - MB1B - Transfer Posting
05 - MB1C - Enter Other Goods Receipt
06 - MB11
Domain: KZBEW - Movement Indicator
Goods movement w/o reference
B - Goods movement for purchase order
F - Goods movement for production order
L - Goods movement for delivery note
K - Goods movement for kanban requirement (WM - internal only)
O - Subsequent adjustment of "material-provided" consumption
W - Subsequent adjustment of proportion/product unit material
LOOP AT I_TAB.
count = sy-tabix.
SELECT SINGLE * FROM ZMM_GI_WIP
WHERE GI_NO = I_TAB-DOCNO AND
GI_DATE = I_TAB-DOCDT.
IF SY-SUBRC = 0.
I_TAB-FLAG = 'C'.
modify i_tab index count.
CONCATENATE 'ERROR GI : ' I_TAB-DOCNO
' WAS ALREADY UPLOADED' INTO I_MSG1.
APPEND I_MSG1.
CLEAR I_TAB-FLAG.
CONTINUE.
ELSE.
CONCATENATE I_TAB-DOCDT+4(2)
I_TAB-DOCDT+6(2)
I_TAB-DOCDT+2(2)
I_TAB-DOCDT+0(2)
INTO G_DATE.
gmhead-pstng_date = G_DATE.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
"01 - MB01 - Goods Receipts for Purchase Order
gmcode-gm_code = '03'.
refresh itab.
clear itab.
SORT I_MAIN BY SOL_DOCNO.
LOOP AT I_MAIN WHERE DOCNO = I_TAB-DOCNO.
IF I_MAIN-GI_TXN_TYPE = 'MGI'.
itab-move_type = '291'.
ENDIF.
itab-mvt_ind = ' '.
itab-plant = I_MAIN-WERKS.
itab-material = I_MAIN-MATNR.
itab-entry_qnt = I_MAIN-ERFMG.
itab-stge_loc = I_MAIN-LGOBE.
itab-ENTRY_UOM = I_MAIN-ERFME.
IF I_MAIN-WERKS = 'MR'.
itab-TR_PART_BA = '11'.
ELSEIF I_MAIN-WERKS = 'MR'.
itab-TR_PART_BA = '12'.
ENDIF.
append itab.
ENDLOOP.
if not itab[] is initial.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gmhead
goodsmvt_code = gmcode
* TESTRUN = ' '
IMPORTING
goodsmvt_headret = mthead
* MATERIALDOCUMENT =
MATDOCUMENTYEAR =
tables
goodsmvt_item = itab
GOODSMVT_SERIALNUMBER =
return = errmsg.
clear errflag.
loop at errmsg.
if errmsg-type eq 'E'.
write:/'Error in function', errmsg-message.
errflag = 'X'.
else.
write:/ errmsg-message.
endif.
move errmsg-message to i_msg1.
append i_msg1.
endloop.
if errflag is initial.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
commit work and wait.
if sy-subrc ne 0.
write:/ 'Error in updating'.
exit.
endif.
endif.
ENDIF.
wait up to 20 seconds.
ENDLOOP. -
Hi All,,
Please give Entire BDC code for MM01 Transaction.
i will change as per my requirement.
I think this is already done by some ABAP Consultants.
plz dont give answers like do recording for that transaction MM01. I know recording...
For time constraiint, I have to complete soon.....
Thanks in Advance
BestRegards,
AnilHi,
The below code is using the Session Method
report ZDS_BDC_MM01
no standard page heading line-size 255.
include bdcrecx1.
*parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record OCCURS 0,
* data element: MATNR
MATNR_001(018),
* data element: MBRSH
MBRSH_002(001),
* data element: MTART
MTART_003(004),
* data element: XFELD
KZSEL_01_004(001),
* data element: XFELD
KZSEL_02_005(001),
* data element: MAKTX
MAKTX_006(040),
* data element: MEINS
MEINS_007(003),
* data element: MAKTX
MAKTX_008(040),
end of record.
*** End generated data section ***
start-of-selection.
*perform open_dataset using dataset.
perform open_group.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME ='C:\DHRUV.TXT'
FILETYPE = 'DAT'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = RECORD
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.
*do.
LOOP AT record.
*read dataset dataset into record.
if sy-subrc <> 0. exit. endif.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
record-KZSEL_02_005.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_006.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_007.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_008.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
*enddo.
ENDLOOP.
perform close_group.
*perform close_dataset using dataset.
*Text elements
* E00 Error opening dataset, return code:
* I01 Session name
* I02 Open session
* I03 Insert transaction
* I04 Close Session
* I05 Return code =
* I06 Error session created
* S01 Session name
* S02 User
* S03 Keep session
* S04 Lock date
* S05 Processing Mode
* S06 Update Mode
* S07 Generate session
* S08 Call transaction
* S09 Error sessn
* S10 Nodata indicator
* S11 Short log
*Messages
* Message class: MS
*613 Please enter a session name and user name
The Below is the coding for the Call Transaction...
report ZDS_BDC_MM01_2
no standard page heading line-size 255.
*include bdcrecx1.
*parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record OCCURS 0,
* data element: MATNR
MATNR_001(018),
* data element: MBRSH
MBRSH_002(001),
* data element: MTART
MTART_003(004),
* data element: XFELD
KZSEL_01_004(001),
* data element: MAKTX
MAKTX_005(040),
* data element: MEINS
MEINS_006(003),
* data element: MTPOS_MARA
MTPOS_MARA_007(004),
end of record.
DATA: FLNAME TYPE STRING.
*** End generated data section ***
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*** MESSAGE******
DATA: BEGIN OF MESSTAB OCCURS 0.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: MATNR TYPE MARA-MATNR,
END OF MESSTAB.
****END OF MESSAGE****
PARAMETERS: FILENAME TYPE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILENAME.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = FILENAME.
start-of-selection.
*perform open_dataset using dataset.
perform open_group.
FLNAME = FILENAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FLNAME
FILETYPE = 'DAT'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = record
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.
LOOP AT record.
DATA:
CNT TYPE I.
CNT = CNT + 1.
REFRESH BDCDATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
record-MATNR_001.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_002.
perform bdc_field using 'RMMG1-MTART'
record-MTART_003.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_004.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_005.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_006.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_007.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
*perform bdc_transaction using 'MM01'.
CALL TRANSACTION 'MM01' USING BDCDATA
MODE 'N'
UPDATE 'A'
MESSAGES INTO MESSTAB.
READ TABLE MESSTAB INTO MESSTAB INDEX CNT.
IF MESSTAB-MSGTYP = 'E'.
MESSTAB-MATNR = RECORD-MATNR_001.
MODIFY MESSTAB INDEX CNT FROM MESSTAB. " TRANSPORTING MATNR.
ENDIF.
ENDLOOP.
FORM OPEN_GROUP.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING CLIENT = SY-MANDT
GROUP = 'MM01'
USER = SY-UNAME
KEEP = 'X'.
ENDFORM.
FORM BDC_INSERT.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
END-OF-SELECTION.
LOOP AT MESSTAB.
IF MESSTAB-MSGTYP = 'E'.
WRITE:/ 'ERROR OCCURED ON MATNR = ',MESSTAB-MATNR , 'MESSAGE : MATNR ALREADY EXISTS IN MARA!!!'.
ENDIF.
ENDLOOP.
perform close_group.
*perform close_dataset using dataset.
*& Form close_group
* text
* --> p1 text
* <-- p2 text
FORM 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. " close_group
*& Form bdc_dynpro
* text
* -->P_0270 text
* -->P_0271 text
FORM bdc_dynpro USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. " bdc_dynpro
*& Form bdc_field
* text
* -->P_0275 text
* -->P_0276 text
FORM bdc_field USING FNAM FVAL.
IF FVAL <> ' '.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM. " bdc_field
*Text elements
* E00 Error opening dataset, return code:
* I01 Session name
* I02 Open session
* I03 Insert transaction
* I04 Close Session
* I05 Return code =
* I06 Error session created
* S01 Session name
* S02 User
* S03 Keep session
* S04 Lock date
* S05 Processing Mode
* S06 Update Mode
* S07 Generate session
* S08 Call transaction
* S09 Error sessn
* S10 Nodata indicator
* S11 Short log
HTH
Regards,
Dhruv Shah -
Need BDC code for Call Transaction of VL31N, which creates Inbound del.s,
Hi Experts,
Is any body does have the BDC (CALL TRANSACTION) code for VL31N transaction, where we can crete INBOUND deliveries from Purc Orders.
Actually, currently am doing by using FM - GN_DELIVERY_CREATE, but, its not given me a chance to incorporate BATCH SPLIT functionality. So, decided to go with BDC
1 - Is this VL31N is Okay for BDC, bcoz, some where I red that, since its a ENJOY tx, its NOT recommended?
2 - Is there any other FM, BAPI to create INBOUND deliveries from POs, which can take care of BATCH SPLIT functionality?
3 - BDC code for VL31N tx.
thanq
Edited by: Srinivas on Jul 29, 2008 1:47 PM1 - Is this VL31N is Okay for BDC, bcoz, some where I red that, since its a ENJOY tx, its NOT recommended?
yes you can do that .
2 - Is there any other FM, BAPI to create INBOUND deliveries from POs, which can take care of BATCH SPLIT functionality?
using BDC we can achieve the Barch split functionality.
3 - BDC code for VL31N tx.
Record using SHDB it will give you. -
Bdc code for transfer of asset plant wise stock transfer (urgent)
hi all,
if anyone has done BDC for this scenario ie.,
bdc for transfer of asset plant wise stock transfer
then plz share its code with me.and if someone has done any modification regarding this scenario then plz let me know that what modification he/she has carried out in this & share the code for the same.
i will be grateful to u for this and promise that i will give points to all ur effort.
Thanks & regards
SanjeevHi Sanjeev,
Do a recording for the transaction using SHDB. Once you are done with the recording save the recording into a zprogram. You have the code.
Regards
Arun -
BDC code for the XD01 and VD01
Hello Masters,
I am new to SAP-ABAP,could anyone help me to get the BDC code to update the customer master data by using the t.code XD01 and VD01.
Thanks
Varsha.SESSION METHOD
report YARINSESSIONBDC2 no standard page heading line-size 255.
data: bdcdata like bdcdata occurs 0 with header line.
data: session like apqi-groupid value 'yar1'.
data: begin of itab occurs 0,
kunnr like lfa1-kunnr,
name1 like lfa1-name1,
pstlz like lfa1-pstlz,
end of itab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'D:\naser.txt'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '|'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = 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.
start-of-selection.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
DEST = FILLER8
GROUP = SESSION
HOLDDATE = FILLER8
KEEP = FILLER1
USER = SY-UNAME
RECORD = FILLER1
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DO.
perform fill_bdc_tab.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'XD02'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDDO.
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.
*include bdcrecx1.
*start-of-selection.
*perform open_group.
*& Form fill_bdc_tab
text
--> p1 text
<-- p2 text
FORM fill_bdc_tab.
clear bdcdata.
refresh bdcdata.
perform bdc_dynpro using 'SAPMF02D' '0101'.
perform bdc_field using 'BDC_CURSOR'
'RF02D-D0110'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02D-KUNNR'
itab-kunnr.
perform bdc_field using 'RF02D-BUKRS'
'0001'.
perform bdc_field using 'RF02D-D0110'
'X'.
perform bdc_dynpro using 'SAPMF02D' '0110'.
perform bdc_field using 'BDC_CURSOR'
'KNA1-PSTLZ'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KNA1-ANRED'
'Company'.
perform bdc_field using 'KNA1-NAME1'
itab-name1.
perform bdc_field using 'KNA1-PFACH'
'GPO'.
perform bdc_field using 'KNA1-ORT01'
'7000091'.
perform bdc_field using 'KNA1-PSTLZ'
itab-pstlz.
perform bdc_field using 'KNA1-PSTL2'
'123456'.
perform bdc_field using 'KNA1-LAND1'
'IN'.
perform bdc_field using 'KNA1-SPRAS'
'EN'.
*perform bdc_transaction using 'XD02'.
*perform close_group.
append bdcdata.
ENDFORM. " fill_bdc_tab
Start new screen *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
Insert field *
FORM BDC_FIELD USING FNAM FVAL.
IF FVAL <> NODATA.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDIF.
ENDFORM.
Reward if useful
Regards
ANUPAM -
How to use bdc code in a report for save button
hi to all can anybody please give some hints that how can i place the BDC code for the save button to pass the values from the editable grid to the standard table here i am sending my code .please advice me.
Moderator Message: Please post only relevant portions of your code. There is a 2,500 character per post limit.
here the second grid is editable.and i have to make changes in the second grid and save it to the standard tables. please advice me resma
Edited by: kishan P on Sep 13, 2010 3:59 PMHi,
I have done that many times. Create a button in the toolbar,say 'SAVE'. Write the code in the subroutine user command.For example :
*& Form USER_COMMAND
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA : REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_VALID TYPE C.
*Code to reflect the changes done in the internal table
IF REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF_GRID.
ENDIF.
IF NOT REF_GRID IS INITIAL.
CALL METHOD REF_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = L_VALID.
ENDIF.
CASE SY-UCOMM.
WHEN 'SAVE'.
PERFORM BDC."Write all you BDC code in this subroutine
ENDCASE.
ENDFORM.
Hope this will help.
Thanks & Regards,
Rock. -
What is the ok code for pup-up screen in BDC
Dear Teches
Hi to all
while doing a BDC in Tr Code f-02 ,my programe is not moving ahead becouse of a Pup-up menu.
Enter is not accepting in that pup-up menu,The pop-up menu is only one option to close is Copy.
So i need the BDC code for that Copy.
B'coz in recording that code is not present.
Plz. Helep me out in this.
Every helpfull Answer will be rewarded with points
Thanks in Advance
ShovanHi,
Save the following in a text file and save in windows desktop,
[FUNCTION]
Command=/H
Title=Debugger
Type=SystemCommand
Run the BDC until where the popup screen appear, now minimise all windows to show desktop where you saved the text file. Click and drag the text file to the popup window, this will activate the debugger and enter field sy-ucomm to see the value. That value will be the okcode value.
Cheers.
...Reward if useful. -
Need bdc program for master recipe
Hi All,
Can any one please give me BDC code for Master Recipe Data Upload or is ther any standard program available to upload Master Recipe data?.
Regards
SathishHi,
Can you share the same to me as well.
as I also have the same requirement
Thanks -
Dear experts,
We have DEV client 150,250. Dev occurs on 150.It has very less data and not configured.
Client 250 has enough data and configured at par with PRD.
Now i want to generate a BDC code for F-02 posting.
In 150 i cannot complete the cycle becuase it is not configured.In 250 i cannot again because
it has no authorization for writing code it says 'SAP system has status not modifiable.'
But i can complete BDC cycle of recording only in 250.
Waiting for your recommendations.The error message sounds a bit like you're trying to generate a program for a recorded BDC in your non-dev client.
Here's what you should do: Do a BDC recording via transaction SHDB in your non-dev client. Then once you are back from the recording and on the screen where you see all your processed screens and fields (windows title starts with something like <i>Transaction Recorder: Change recording...</i>), you will see at the top right a button for exporting the recording to your presentation server as a text file.
So save the recording on your PC and then log into the dev client. Here start to also record a BDC session, but just do a dummy one (i.e. enter any transaction code and immediately go back). So once you're back on the screen with the recorded screens and field values, choose the import button to upload your saved session.
Now you have the saved session in your dev client and you can generate programs or whatever you want to do there.
Cheers, harald -
Hi All,
I need BDC code for BOM (cs01), i don't know how to handle "Table Control" in BDC.
Flat file is also required. Because, i think flat file arrangement will be differ from regular flat file format.
It is very urgent.
Thanks & Regards,
SrinivasHi Satya,
To handle table control you need to do the recording of cs01 accordingly.
Record the transaction entring the header data and when you come to the table control, enter one or two rows and press new entries, which gives you new rows for value entry. Finally once you are done with the recording, get the program from the recording.
At the point where you entered value for table control you can see the row/colum indexes. The "New Entry" okcode will give you an initialized index for the new rows.
you need to dynamically increment the indexes for the table control while you loop throught the table control data (item data).
after you pass say 5 to 10 records to the table control, you have to call the OKCODE for the "New Entry" button which gives you fresh rows for value entry and you need to initialize the indexes for the table control rows. This cycle continues until you complete the entried for table control and then proceed with further processing.
Reward Points if this helps.
-Thank you- -
How to put a report which contains code for BDC in background
Hello Experts ,
Please provide your valuable opinions on following issue,
My BDC execution is taking longer time and it gives time out error. To avoid this problem i have created a separate report which l contains the BDC code (Call transaction ) and i have put this report for background execution. But upon doing this My BDC code is not performing the transaction call which it was performing when it was executed individually. In sm37 it shown the job that i am creating but nothing is actually happening as a result of transaction call.
The code that i have written is :
RFC code
SUBMIT ZREPORT AND RETURN.
RFC end
Z_REPORT .
PERFORM open_job.
PERFORM get_print_parameters.
PERFORM job_submit. here in Submit i have specified the another report name(zbdcreport) which contains the actual logic for bdc
PERFORM job_close.
Report END.
zbdcreport
The call transaction is as follows :
( CALL TRANSACTION TCODE USING BDCDATA
MODE 'N' "CTUMODE "N
UPDATE 'S' "CUPDATE "S
MESSAGES INTO MESSTAB .)
end zbdcreport
Can anybody provide the reason for the error .
Regards,
UmaHi
Check the code using this...
DATA: number TYPE tbtcjob-jobcount,
name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
print_parameters TYPE pri_params.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = name
IMPORTING
jobcount = number
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc = 0.
SUBMIT submitable TO SAP-SPOOL
SPOOL PARAMETERS print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB name NUMBER number
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = number
jobname = name
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF. -
BDC OK CODE FOR ENTER NOT RECORDING
I m creating a BDC Programme for uploading OLD PO date from excel to SAP System.
All PO's are Service PO.
PO's date and Delivery Date is in back date.
My programme working fine.
But i have to press enter manually due to PO Date = back date and Delivery date is also back date.
SHDB unable to record this event.
How to record this event.
Is there any way to disable system messages during BDC Programme.
When I press enter two times my programme runs very well.
Kindly help me.
Its very much urgent.
Code is give below.
REPORT zbdcme21n
NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA : l_file TYPE rlgrap-filename.
DATA: e_group_opened.
PARAMETERS session RADIOBUTTON GROUP ctu. "create session
*DATA : session RADIOBUTTON GROUP ctu.
DATA : group(12). "group name of session
group = 'BDC'.
*PARAMETERS: user(12) DEFAULT sy-uname. "user for session in batch
DATA : user(12).
user = sy-uname.
*DATA : keep AS CHECKBOX. "' ' = delete session if finished
DATA : keep TYPE checkbox.
keep = 'X'.
*PARAMETERS: holddate LIKE sy-datum. "'X' = keep session if finished
DATA : holddate LIKE sy-datum.
holddate = sy-datum.
PARAMETERS ctu RADIOBUTTON GROUP ctu. "call transaction
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF i_tab OCCURS 0, "excel data stored in this file.
row TYPE alsmex_tabline-row,
col TYPE alsmex_tabline-col,
value TYPE alsmex_tabline-value,
END OF i_tab.
DATA : BEGIN OF wa_line1 OCCURS 0, "excel data stored in this file.
row TYPE alsmex_tabline-row,
col TYPE alsmex_tabline-col,
value TYPE alsmex_tabline-value,
srno TYPE i,
END OF wa_line1.
DATA : wa_line2 LIKE wa_line1 OCCURS 0 WITH HEADER LINE .
DATA : wa_hdr1 LIKE wa_line1 OCCURS 0 WITH HEADER LINE .
DATA : wa_hdr LIKE i_tab OCCURS 0 WITH HEADER LINE .
DATA : wa_line LIKE i_tab OCCURS 0 WITH HEADER LINE .
DATA : w_cnt TYPE i . "store total no of pos
DATA : w_hdr_counter VALUE 1. "for header line count
DATA : w_line_counter VALUE 1. "for Line Item Counter.
w_cnt = 0.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
PARAMETER: dataset TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR dataset.
PERFORM upload_file.
*include bdcrecx1.
START-OF-SELECTION.
PERFORM process_itab.
*include bdcrecx1.
START-OF-SELECTION.
PERFORM open_group.
**********************start for header
w_hdr_counter = 1.
WHILE w_hdr_counter <= w_cnt.
PERFORM bdc_dynpro USING 'SAPMM06E' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06E-BEDAT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
READ TABLE wa_hdr1 WITH KEY col = 2 srno = w_hdr_counter.
PERFORM bdc_field USING 'EKKO-LIFNR'
wa_hdr1-value. "'800000'.
READ TABLE wa_hdr1 WITH KEY col = 3 srno = w_hdr_counter.
PERFORM bdc_field USING 'RM06E-BSART'
wa_hdr1-value. "'ZS'.
READ TABLE wa_hdr1 WITH KEY col = 4 srno = w_hdr_counter.
PERFORM bdc_field USING 'RM06E-BEDAT'
wa_hdr1-value. " '14.01.2008'.
PERFORM bdc_field USING 'RM06E-LPEIN'
'T'.
READ TABLE wa_hdr1 WITH KEY col = 13 srno = w_hdr_counter.
PERFORM bdc_field USING 'RM06E-EEIND'
wa_hdr1-value. "'14.01.2008'. "Delivery Date
PERFORM bdc_field USING 'RM06E-LPEIN'
'T'.
READ TABLE wa_hdr1 WITH KEY col = 6 srno = w_hdr_counter.
PERFORM bdc_field USING 'EKKO-EKORG'
wa_hdr1-value. "'serv'.
READ TABLE wa_hdr1 WITH KEY col = 7 srno = w_hdr_counter.
PERFORM bdc_field USING 'EKKO-EKGRP'
wa_hdr1-value. "'dce'. Purchase Group
READ TABLE wa_hdr1 WITH KEY col = 8 srno = w_hdr_counter.
PERFORM bdc_field USING 'RM06E-EPSTP'
wa_hdr1-value. "'d'. Item Category
READ TABLE wa_hdr1 WITH KEY col = 9 srno = w_hdr_counter.
PERFORM bdc_field USING 'RM06E-KNTTP'
wa_hdr1-value. "'p'. Account Asign Category
READ TABLE wa_hdr1 WITH KEY col = 10 srno = w_hdr_counter.
PERFORM bdc_field USING 'RM06E-WERKS'
wa_hdr1-value. "'1001'.Plant
READ TABLE wa_hdr1 WITH KEY col = 11 srno = w_hdr_counter.
PERFORM bdc_field USING 'RM06E-LGORT'
wa_hdr1-value. " '1101'. Store Location
READ TABLE wa_hdr1 WITH KEY col = 12 srno = w_hdr_counter.
PERFORM bdc_field USING 'RM06E-MATKL'
wa_hdr1-value. "'c003'. Material Group
PERFORM bdc_dynpro USING 'SAPLMLSP' '0200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
********************end of Header Data*******************
data i type n value 1.
data bfield type string.
LOOP AT wa_line1 WHERE col = 1 AND srno = wa_hdr1-srno.
READ TABLE wa_line2 WITH KEY COL = 14 SRNO = wa_hdr1-srno ROW = wa_line1-ROW.
PERFORM bdc_field USING 'RM11P-HEADTEXT'
wa_line2-value. " 'Earthwork text'.
concatenate 'ESLL-SRVPOS(' i ')' into bfield.
PERFORM bdc_field USING 'BDC_CURSOR'
bfield. " 'ESLL-SRVPOS(01)'. "increase counter
PERFORM bdc_field USING 'RM11P-NEW_ROW'
'10'.
READ TABLE wa_line2 WITH KEY COL = 15 SRNO = wa_hdr1-srno ROW = wa_line1-ROW.
PERFORM bdc_field USING bfield "'ESLL-SRVPOS(01)'
wa_line2-value. "'5000000000'.
concatenate 'ESLL-MENGE(' i ')' into bfield.
READ TABLE wa_line2 WITH KEY COL = 16 SRNO = wa_hdr1-srno ROW = wa_line1-ROW.
PERFORM bdc_field USING bfield "'ESLL-MENGE(01)' "qty
wa_line2-value. "'15'.
concatenate 'ESLL-MEINS(' i ')' into bfield.
READ TABLE wa_line2 WITH KEY COL = 17 SRNO = wa_hdr1-srno ROW = wa_line1-ROW.
PERFORM bdc_field USING bfield "'ESLL-MEINS(01)'
wa_line2-value. "'ft3'.
concatenate 'ESLL-TBTWR(' i ')' into bfield.
READ TABLE wa_line2 WITH KEY COL = 18 SRNO = wa_hdr1-srno ROW = wa_line1-ROW.
PERFORM bdc_field USING bfield " 'ESLL-TBTWR(01)'
wa_line2-value. "'150'.
PERFORM bdc_field USING 'BDC_OKCODE' "Manually added
'/00'.
PERFORM bdc_dynpro USING 'SAPLMLSK' '0200'.
concatenate 'ESKN-PS_PSP_PNR' i ')' into bfield.
PERFORM bdc_field USING 'BDC_CURSOR'
'ESKN-PS_PSP_PNR(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'VRTKZ1'
'X'.
concatenate 'ESKN-SAKTO(' i ')' into bfield.
READ TABLE wa_line2 WITH KEY COL = 19 SRNO = wa_hdr1-srno ROW = wa_line1-ROW.
PERFORM bdc_field USING 'ESKN-SAKTO(01)' "GL Account No.
wa_line2-value. " '6010010'.
concatenate 'ESKN-PS_PSP_PNR(' i ')' into bfield.
READ TABLE wa_line2 WITH KEY COL = 20 SRNO = wa_hdr1-srno ROW = wa_line1-ROW.
PERFORM bdc_field USING 'ESKN-PS_PSP_PNR(01)'
wa_line2-value. " 'HR/KMP-KU'. "WBS Element
PERFORM bdc_dynpro USING 'SAPLMLSK' '0200'.
PERFORM bdc_field USING 'BDC_CURSOR'
'ESLL-INTROW'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BACK'.
PERFORM bdc_field USING 'VRTKZ1'
'X'.
PERFORM bdc_dynpro USING 'SAPLMLSP' '0200'.
i = i + 1.
ENDLOOP.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BACK'.
PERFORM bdc_field USING 'VRTKZ1'
'X'.
PERFORM bdc_dynpro USING 'SAPLMLSP' '0200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'RM11P-HEADTEXT'
'Earthwork text'.
*perform bdc_field using 'BDC_CURSOR' "Start Service Line 2
'ESLL-SRVPOS(02)'.
*perform bdc_field using 'RM11P-NEW_ROW'
'10'.
*perform bdc_field using 'ESLL-SRVPOS(02)'
'5000000006'.
*perform bdc_field using 'ESLL-MENGE(02)'
'10'.
*perform bdc_field using 'ESLL-MEINS(02)'
'kmk'.
*perform bdc_field using 'ESLL-TBTWR(02)'
'500'.
*perform bdc_dynpro using 'SAPLMLSK' '0200'.
*perform bdc_field using 'BDC_CURSOR'
'ESLL-INTROW'.
*perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'VRTKZ1'
'X'.
*perform bdc_dynpro using 'SAPLMLSK' '0200'.
*perform bdc_field using 'BDC_CURSOR'
'ESKN-PS_PSP_PNR(01)'.
*perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'VRTKZ1'
'X'.
*perform bdc_field using 'ESKN-SAKTO(01)'
'6010010'.
*perform bdc_field using 'ESKN-PS_PSP_PNR(01)'
'HR/KMP-KU'.
*perform bdc_dynpro using 'SAPLMLSK' '0200'.
*perform bdc_field using 'BDC_CURSOR'
'ESLL-INTROW'.
*perform bdc_field using 'BDC_OKCODE'
'=BACK'.
*perform bdc_field using 'VRTKZ1'
'X'.
*perform bdc_dynpro using 'SAPLMLSP' '0200'.
*perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'RM11P-HEADTEXT'
'Earthwork text'.
*perform bdc_field using 'BDC_CURSOR'
'ESLL-KTEXT1(01)'.
*perform bdc_field using 'RM11P-NEW_ROW'
'10'.
*perform bdc_dynpro using 'SAPLMLSP' '0200'.
*perform bdc_field using 'BDC_OKCODE'
'=ESB'.
*perform bdc_field using 'RM11P-HEADTEXT'
'Earthwork text'.
*perform bdc_field using 'BDC_CURSOR'
'ESLL-KTEXT1(01)'.
*perform bdc_field using 'RM11P-NEW_ROW'
'10'.
*perform bdc_dynpro using 'SAPMM06E' '0120'.
*perform bdc_field using 'BDC_CURSOR'
'RM06E-EBELP'.
*perform bdc_field using 'BDC_OKCODE'
'=MALL'.
*perform bdc_field using 'RM06E-EBELP'
'10'.
PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06E-EBELP'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=KOPF'.
PERFORM bdc_field USING 'RM06E-EBELP'
'10'.
PERFORM bdc_dynpro USING 'SAPMM06E' '0101'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EKKO-EKGRP'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=TXK'.
*perform bdc_field using 'EKKO-EKGRP'
'DCE'.
*perform bdc_field using 'EKKO-PINCR'
'10'.
*perform bdc_field using 'EKKO-UPINC'
'1'.
*perform bdc_field using 'EKKO-WAERS'
'INR'.
*perform bdc_field using 'EKKO-WKURS'
' 1.00000'.
PERFORM bdc_dynpro USING 'SAPMM06E' '0103'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RM06E-LTEX1(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM bdc_field USING 'RM06E-LTEX1(01)'
'Old PO no.'.
*perform bdc_transaction using 'ME21'.
w_hdr_counter = w_hdr_counter + 1.
ENDWHILE.
CALL TRANSACTION 'ME21' USING bdcdata MODE 'A'.
PERFORM close_group.
***************forms************
FORM upload_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
*def_filename = ' '
*def_path = ' '
*mask = ' '
mode = '0'
title = 'Choose the Appropriate excel sheet for service PO upload'
IMPORTING
filename = dataset
*EXCEPTIONS
*inv_winsys = 01
*no_batch = 02
*selection_cancel = 03
*selection_error = 04
l_file = dataset.
PERFORM read_exceldata.
ENDFORM. "UPLOAD_FILE
*& Form READ_EXCELDATA
text
FORM read_exceldata.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = l_file
i_begin_col = 1
i_begin_row = 2
i_end_col = 25
i_end_row = 4
TABLES
intern = i_tab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
ENDFORM. "READ_EXCELDATA
create batchinput session *
(not for call transaction using...) *
FORM open_group.
IF session = 'X'.
SKIP.
WRITE: /(20) 'Create group'(i01), group.
SKIP.
open batchinput group
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = group
user = user
keep = keep
holddate = holddate.
WRITE: /(30) 'BDC_OPEN_GROUP'(i02),
(12) 'returncode:'(i05),
sy-subrc.
ENDIF.
ENDFORM. "OPEN_GROUP
end batchinput session *
(call transaction using...: error session) *
FORM close_group.
IF session = 'X'.
close batchinput group
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /(30) 'BDC_CLOSE_GROUP'(i04),
(12) 'returncode:'(i05),
sy-subrc.
ELSE.
IF e_group_opened = 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE: /.
WRITE: /(30) 'Fehlermappe wurde erzeugt'(i06).
e_group_opened = ' '.
ENDIF.
ENDIF.
ENDFORM. "CLOSE_GROUP
*& Form BDC_DYNPRO
text
-->PROGRAM text
-->DYNPRO text
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
****bdc field************
FORM bdc_field USING fnam fval.
IF FVAL <> NODATA.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDIF.
ENDFORM. "BDC_FIELD
FORM process_itab.
APPEND LINES OF i_tab TO wa_hdr .
DELETE wa_hdr WHERE col > 13 .
APPEND LINES OF i_tab TO wa_line .
DELETE wa_line WHERE col <> 1 AND col < 14 .
DATA : w_sr TYPE i.
w_sr = 0.
LOOP AT wa_hdr.
IF wa_hdr-col = 1.
w_sr = wa_hdr-value.
ENDIF.
wa_hdr1-row = wa_hdr-row.
wa_hdr1-col = wa_hdr-col.
wa_hdr1-value = wa_hdr-value.
wa_hdr1-srno = w_sr.
APPEND wa_hdr1.
w_cnt = wa_hdr-row.
ENDLOOP.
w_sr = 0.
LOOP AT wa_line.
IF wa_line-col = 1.
w_sr = wa_line-value.
ENDIF.
wa_line1-row = wa_line-row.
wa_line1-col = wa_line-col.
wa_line1-value = wa_line-value.
wa_line1-srno = w_sr.
APPEND wa_line1.
ENDLOOP.
w_sr = 0.
CLEAR wa_line2.
LOOP AT wa_line1.
wa_line2-row = wa_line1-row.
wa_line2-col = wa_line1-col.
wa_line2-value = wa_line1-value.
wa_line2-srno = wa_line1-srno.
APPEND wa_line2.
ENDLOOP.
ENDFORM. "PROCESS_ITAB
***************forms************Hi Pradeep
I find there is a problem in your code
When ever you use
PERFORM bdc_field USING 'BDC_OKCODE'
you should follow it up with
PERFORM bdc_dynpro USING <prg name> <screen number>
Please find code below with changes from a part of your code
PERFORM bdc_field USING 'RM06E-MATKL'
wa_hdr1-value. "'c003'. Material Group
* comment this statement is not needed now.
* PERFORM bdc_dynpro USING 'SAPLMLSP' '0200'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
READ TABLE wa_line2 WITH KEY COL = 14 SRNO = wa_hdr1-srno ROW = wa_line1-ROW.
* Put the bdc_dynpro for the prg name and screen number (I might be wrong with prg name and
* Screen number
PERFORM bdc_dynpro USING 'SAPLMLSK' '0200'.
Reward points as this will definitely help you
Edited by: Sriram Chandran on Mar 15, 2008 4:39 PM
Maybe you are looking for
-
Caller ID not working on Curve 9300
When i receive calls, caller name is not appearing even though the number is saved with specific name in my mobile.
-
What are the Different Profiles and what is the Neeed for profiles?
Hello Basis Gurus, I want to know about the profiles.. I know How to Maintain and I don't Know exactly what is the need pls any one send me detail analysys of the profiles ..i will give more reward points. 1.what are User profiles and trans
-
Labview FPGA for beginners.
Hello. I have no idea what labview is and how to work with this. I have had some experience with Xilinx 12.1 EDK (microblaze and VHDL). I tried to install labview and labview fpga module. It asked for some drivers and I continued, the program said th
-
Connecting 30" display to 2013 Macbook Air
Is it possible to get full 2560x1600 resolution out of 30" DELL U3014 by connecting to June-2013 Macbook Air? If yes, at what refresh rate, and what adapter should I use for this?
-
Fixed-Rate Age-Based Insurance Plan
Hi SAP Benefits experts, We have a new insurance offering this year wherein employee rates are determined by the employee's age at the time of initial enrollment. If an employee enrolls at, say age 25, his or her rates will not increase as the ye