‎2008 Jun 13 6:04 AM
Hi...
Iam writing call transaction program to FB01... i recorded some fields...
and here what are steps i hav to follow to write this program...
and please give me clear explination at the part file uploading from application server....
and iam also getting error at parameters pasing of error messages table??
Expect max: marks for your valueble time...
Thnaks ,
Naveen.I
‎2008 Jun 13 6:16 AM
Hi Naveen,
Please follow these steps :
1. Upload the data from application/presentation server .
a. To upload data from application server.
wf_filename : application file path
OPEN DATASET wf_filename FOR INPUT IN BINARY MODE.
If sy-subrc eq 0.
READ DATASET wf_filename INTO wf_xyz.
If the application file is tab delimited file.
SPLIT wf_xyz AT co_tab INTO TABLE tb_itab.
b. To upload data from Presentation server.
Use UPLOAD/WS_UPLOAD/GUI_UPLOAD or DATASETS for upload data from
local file to internal table tb_itab.
2. Validate the tb_itab data before performing BDC .
3. Now loop at tb_itab and populate the BDC data table.
CALL TRANSACTION tcode USING lt_bdcdata
MODE 'E' MESSAGES INTO it_message.
LOOP AT it_message INTO message.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = message-msgid
lang = 'EN'
no = message-msgnr
v1 = message-msgv1
v2 = message-msgv2
v3 = message-msgv3
v4 = message-msgv4
IMPORTING
msg = msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc EQ 0.
WRITE / msg.
ENDIF. " IF sy-subrc EQ 0.
ENDLOOP.
Regards,
Sachin M M
Edited by: Sachin Mathapati on Jun 13, 2008 10:46 AM
‎2008 Jun 13 6:16 AM
Hi Naveen,
Please follow these steps :
1. Upload the data from application/presentation server .
a. To upload data from application server.
wf_filename : application file path
OPEN DATASET wf_filename FOR INPUT IN BINARY MODE.
If sy-subrc eq 0.
READ DATASET wf_filename INTO wf_xyz.
If the application file is tab delimited file.
SPLIT wf_xyz AT co_tab INTO TABLE tb_itab.
b. To upload data from Presentation server.
Use UPLOAD/WS_UPLOAD/GUI_UPLOAD or DATASETS for upload data from
local file to internal table tb_itab.
2. Validate the tb_itab data before performing BDC .
3. Now loop at tb_itab and populate the BDC data table.
CALL TRANSACTION tcode USING lt_bdcdata
MODE 'E' MESSAGES INTO it_message.
LOOP AT it_message INTO message.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = message-msgid
lang = 'EN'
no = message-msgnr
v1 = message-msgv1
v2 = message-msgv2
v3 = message-msgv3
v4 = message-msgv4
IMPORTING
msg = msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc EQ 0.
WRITE / msg.
ENDIF. " IF sy-subrc EQ 0.
ENDLOOP.
Regards,
Sachin M M
Edited by: Sachin Mathapati on Jun 13, 2008 10:46 AM
‎2008 Jun 13 6:52 AM
Hi,
Please go through the following steps.
1) Declare internal tables consisting of the fields in the transaction, BDCDATA , BDCMSGCOLL .
I took an eg of XK01.
TY_* are types with the the fields .
DATA:
I_XK01 TYPE TABLE OF TY_XK01,
"XK01 STRUCTURE WORK AREA I_BDCDATA TYPE TABLE OF BDCDATA,
"BDC DATA INTERNAL TABLE
I_BDCMSGCOLL TYPE TABLE OF BDCMSGCOLL,
" for handling messages
*workareas
DATA: WA_XK01 TYPE TY_XK01, "XK01 STRUCTURE WORK AREA
WA_BDCDATA TYPE BDCDATA, "BDC DATA WORK AREA
WA_BDCMSGCOLL TYPE BDCMSGCOLL, "BDCMSGCOLL WORK AREA
2) Selection Screen with parameters for file to upload with F4 functionality . I used F4_DXFILENAME_TOPRECURSION'
this can be used for both APPLICATION as well as PRESENTATION server.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_PRES RADIOBUTTON GROUP R1 USER-COMMAND UC DEFAULT 'X' ,
P_APP RADIOBUTTON GROUP R1.
SELECTION-SCREEN : END OF BLOCK B1.
SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS : P_SRCFIL LIKE RLGRAP-FILENAME OBLIGATORY DEFAULT 'D:\Documents and Settings\Desktop\BDCDAT.txt' ,
SELECTION-SCREEN : END OF BLOCK B2.
3) F4 functionality for selecting file.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_SRCFIL.
IF P_PRES = 'X'.
A for application and P for presentation*******
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
I_LOCATION_FLAG = 'A'
I_SERVER = ' '
I_PATH = SEARCH_DIR
FILEMASK = C_FNH_MASK
FILEOPERATION = 'R'
IMPORTING
O_PATH = FILE_PATH
EXCEPTIONS
RFC_ERROR = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
FILE_NAME = FILE_PATH.
ENDIF.
4) For uploading the data from flat file we use GUI_UPLOAD from presentation server and data sets for application server.
START-OF-SELECTION.
IF P_PRES = 'X'.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILE_NAME
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = I_XK01
EXCEPTIONS
FILE_OPEN_ERROR = 1
BAD_DATA_FORMAT = 8.
ELSEIF P_APP = 'X'.
OPEN DATASET FILE_PATH IN TEXT MODE FOR INPUT ENCODING DEFAULT.
IF SY-SUBRC <> 0.
MESSAGE I001(ZGEMSCONV) .
LEAVE TO TRANSACTION 'ZCMMVEN_MAS'.
ENDIF.
ENDIF.
DO.
READ DATASET FILE_PATH INTO WA_XK01.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
APPEND WA_XK01 TO I_XK01.
ENDDO.
CLOSE DATASET FILE_PATH.
ELSEIF P_APP = 'X'.
PERFORM APP_UPLOAD_DATA.
ENDIF.
5) Now fill the BDCDATA table using the uploaded data.
LOOP AT I_XK01 INTO WA_XK01.
.
.
.
PERFORM BDC_DYNPRO USING 'SAPMF02K' '0111'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'SZA1_D0100-TITLE_MEDI'.
PERFORM BDC_FIELD USING 'ADDR1_DATA-NAME1'
WA_XK01-NAME1.
.
.
CALL TRANSACTION 'XK01' USING I_BDCDATA MODE 'A' UPDATE 'S' MESSAGES INTO I_BDCMSGCOLL.
REFRESH I_BDCDATA.
endloop.
6)Now format messages from BDCMSGCOLL
LOOP AT I_BDCMSGCOLL INTO WA_BDCMSGCOLL.
&----
*& FORMATTING MESSAGES
&----
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = WA_BDCMSGCOLL-MSGID
LANG = WA_BDCMSGCOLL-MSGSPRA
NO = WA_BDCMSGCOLL-MSGNR
V1 = WA_BDCMSGCOLL-MSGV1
V2 = WA_BDCMSGCOLL-MSGV2
V3 = WA_BDCMSGCOLL-MSGV3
V4 = WA_BDCMSGCOLL-MSGV4
IMPORTING
MSG = MESSG.
IF WA_BDCMSGCOLL-MSGTYP = 'S'.
"SUCCESS MESSAGE
WA_SUCCESS-MESSG = MESSG.
WRITE: / messg.
ELSE if WA_BDCMSGCOLL-MSGTYP = 'E'.
WA_ERROR-MESSG = MESSG.
"ERROR MESSAGE
WRITE: / messg. ENDIF.
ENDLOOP.
********************************************
hope this gives a brief idea for writing program.
Thanks and Regards
********************************
FORM BDC_DYNPRO USING PROGRAM LIKE BDCDATA-PROGRAM DYNPRO LIKE BDCDATA-DYNPRO.
CLEAR WA_BDCDATA.
WA_BDCDATA-PROGRAM = PROGRAM.
WA_BDCDATA-DYNPRO = DYNPRO.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM.
*************************
FORM BDC_FIELD USING FNAM LIKE BDCDATA-FNAM FVAL TYPE ANY .
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = FNAM.
WA_BDCDATA-FVAL = FVAL.
APPEND WA_BDCDATA TO I_BDCDATA.
ENDFORM.