‎2007 May 14 11:58 AM
Hi,
Iam uploading the data by using call transaction method using Tcode ff67.In this when
i upload the data using mode A iam able to get desired output(ie if there is any error in the input file it is showing the error message).
but by using the mode N iam not able to get the error messages.The record is updating.
iam attaching the code below
&----
START-OF-SELECTION.
&----
CLEAR gu_upload.
REFRESH gu_upload.
&----
UPLOAD THE DATA FROM FLAT FILE TO INTERNAL TABLE
&----
PERFORM file_upload.
iopt-dismode = c_mode.
iopt-updmode = c_upd.
iopt-defsize = c_def_size.
&----
POPULATE THE DATA THROUGHSCREENS
&----
PERFORM bdc_upload.
&----
END-OF-SELECTION.
&----
*DISPLY THE ERROR RECORDS
PERFORM DISPLAY-DATA.
----
FORM file_upload *
----
FORM file_upload.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = c_begcol
i_begin_row = c_begrow
i_end_col = c_endcol
i_end_row = c_endrow
TABLES
intern = int_count
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
LOOP AT int_count.
ASSIGN COMPONENT int_count-col OF STRUCTURE gu_upload TO <fs>.
IF sy-subrc NE 0.
EXIT.
ENDIF.
<fs> = int_count-value.
AT END OF row.
APPEND gu_upload.
CLEAR gu_upload.
ENDAT.
ENDLOOP.
*kishhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
LOOP AT gu_upload.
itab-vgman = gu_upload-vgman.
itab-valut = gu_upload-valut.
itab-kwbtr = gu_upload-kwbtr.
itab-chect_kf = gu_upload-chect_kf.
APPEND itab.
ENDLOOP.
*kishiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
ENDFORM. "file_upload
&----
*& Form BDC_UPLOAD
&----
FORM bdc_upload.
LOOP AT gu_upload.
CLEAR bdcdata.
REFRESH bdcdata.
&----
*& POPULATE THE DATA FOR FIRST SCREEN
&----
perform bdc_dynpro using 'SAPMF40K' '0101'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-JNAME'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'FEBMKA-BUKRS'
'IN14'.
perform bdc_field using 'FEBMKA-HBKID'
gu_upload-hbkid.
perform bdc_field using 'FEBMKA-HKTID'
gu_upload-hktid.
perform bdc_field using 'FEBMKA-AZNUM'
gu_upload-aznum.
perform bdc_field using 'FEBMKA-AZDAT'
gu_upload-azdat.
perform bdc_field using 'FEBMKA-SSALD'
gu_upload-ssald.
perform bdc_field using 'FEBMKA-ESALD'
gu_upload-esald.
perform bdc_field using 'FEBMKA-BUDTM'
gu_upload-budtm.
perform bdc_field using 'FEBMKA-MNAM1'
gu_upload-mnam1.
perform bdc_field using 'FEBMKA-JNAME'
gu_upload-jname.
&----
*& POPULATE THE DATA FOR SECOND SCREEN
&----
DATA : fnam(20) TYPE c,
idx TYPE c.
MOVE 1 TO idx.
LOOP AT itab.
PERFORM bdc_dynpro USING 'SAPMF40K' '8000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'FEBMKK-CHECT_KF(03)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
CONCATENATE 'FEBMKA-VGMAN(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam
itab-vgman.
CONCATENATE 'FEBEP-VALUT(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itab-valut.
CONCATENATE 'FEBMKA-KWBTR(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itab-kwbtr.
CONCATENATE 'FEBMKK-CHECT_KF(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itab-chect_kf.
idx = idx + 1.
ENDLOOP.
perform bdc_dynpro using 'SAPMF40K' '8000'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKK-CHECT_KF(01)'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
&----
*& POPULATE THE DATA FOR FOURTH SCREEN
&----
perform bdc_dynpro using 'SAPMF40K' '0101'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-BUKRS'.
perform bdc_field using 'BDC_OKCODE'
'=BUCH'.
perform bdc_field using 'FEBMKA-BUKRS'
'IN14'.
perform bdc_field using 'FEBMKA-HBKID'
gu_upload-hbkid.
perform bdc_field using 'FEBMKA-HKTID'
gu_upload-hktid.
perform bdc_field using 'FEBMKA-AZNUM'
gu_upload-aznum.
perform bdc_field using 'FEBMKA-AZDAT'
gu_upload-azdat.
perform bdc_field using 'FEBMKA-SSALD'
gu_upload-ssald.
perform bdc_field using 'FEBMKA-ESALD'
gu_upload-esald.
perform bdc_field using 'FEBMKA-BUDTM'
gu_upload-budtm.
perform bdc_field using 'FEBMKA-MNAM1'
gu_upload-mnam1.
perform bdc_field using 'FEBMKA-JNAME'
gu_upload-jname.
*perform bdc_dynpro using 'SAPMF40K' '0101'.
*perform bdc_field using 'BDC_OKCODE'
'/EENDE'.
*perform bdc_field using 'BDC_CURSOR'
'FEBMKA-BUKRS'.
perform bdc_dynpro using 'SAPMF40K' '0101'.
perform bdc_field using 'BDC_OKCODE'
'/EABBR'.
perform bdc_field using 'BDC_CURSOR'
'FEBMKA-BUKRS'.
&----
*& USING THE CALL TRANSACTION
&----
PERFORM call_transaction.
CLEAR BDCDATA. "<--- Add here
REFRESH BDCDATA. "<--- Add here
*
ENDLOOP.
ENDFORM. " BDC_UPLOAD
&----
*& Form VALIDATE_INPUT_FILE
&----
FORM validate_input_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_path = ' c:\ '
mask = ',.txt,.*.'
mode = 'O'
title = 'Upload '
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
IF sy-subrc <> 0 AND sy-subrc <> 3.
MESSAGE e100(zm) WITH text-007.
ENDIF.
ENDFORM. " VALIDATE_INPUT_FILE
----
Start new screen *
----
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "bdc_dynpro
----
Insert field *
----
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "bdc_field
&----
*& Form CALL_TRANSACTION
&----
FORM call_transaction.
DATA: l_index LIKE sy-tabix.
CALL TRANSACTION c_tcode USING bdcdata
MODE c_mode
update 'S'
MESSAGES INTO messtab.
*POPULATE THE ERROR RECORDS INTO INTERNAL TABLE
IF SY-SUBRC NE 0.
GU_DOWNLOAD-ESALD = GU_UPLOAD-ESALD.
GU_DOWNLOAD-SSALD = GU_UPLOAD-SSALD.
GU_DOWNLOAD-BUDTM = GU_UPLOAD-BUDTM.
GU_DOWNLOAD-VGMAN = GU_UPLOAD-VGMAN.
GU_DOWNLOAD-VALUT = GU_UPLOAD-VALUT.
GU_DOWNLOAD-KWBTR = GU_UPLOAD-KWBTR.
GU_DOWNLOAD-CHECT_KF = GU_UPLOAD-CHECT_KF.
APPEND GU_DOWNLOAD.
*DISPLAY THE PROGRESS OF PROCESS
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = 'Downloading is in process'.
.
*DOWNLOADING THE ERROR RECORD
LV_OUT = P_FNAME2.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = LV_OUT
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = GU_DOWNLOAD.
ENDIF.
IF NOT messtab[] IS INITIAL.
PERFORM format_message.
ENDIF.
ENDFORM. " CALL_TRANSACTION
&----
*& Form DISPLAY-DATA
&----
FORM display-data.
SKIP.
WRITE: 'SY-SUBRC' , sy-subrc.
ENDFORM. " DISPLAY-DATA
----
FORM FORMAT_MESSAGE *
----
FORM format_message.
DATA: l_msg(100),
l_index LIKE sy-tabix.
LOOP AT messtab.
READ TABLE gu_upload INDEX l_index.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = messtab-msgid
lang = sy-langu
no = messtab-msgnr
v1 = messtab-msgv1
v2 = messtab-msgv2
v3 = messtab-msgv3
v4 = messtab-msgv4
IMPORTING
msg = l_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
WRITE:/ l_msg.
ENDLOOP.
WRITE:/ l_msg.
ENDFORM.
‎2007 May 14 1:19 PM
Hi
This is Vijay..
can anyone help me from this...
Is there any difference in the output when we select the Mode as A and N...
‎2007 May 14 12:03 PM
Hi,
Use mode 'E' for displaying the error, in mode N no error messges are displayed.
Regards,
Sonika
‎2007 May 14 1:19 PM
Hi
This is Vijay..
can anyone help me from this...
Is there any difference in the output when we select the Mode as A and N...
‎2007 May 14 1:27 PM
Hi Vijay,
As explained above
there is no diff in output in both mode,
the diff lies in displaying the screen during BDC execution
With A mode all screen will be dispalyed , with N it will be executed in background.and will not stop processing at Errorenous record.
Regards,
Sonika
‎2007 May 14 2:50 PM
Hi Vijay,
Yes definetly there is an difference between mode A and N.
When you are executing in back ground, both will behaves like same in case of result.
But when you are using in foreground, Some errors will be seen ,
Example, especially when you are using Quantity and unit of measurement.
Suppose, You are coding Unit of measurment and data is not getting populated.
That means, data is not coming from file. The if is fore ground, call transaction will be successful.
If the same is ran in background. It shows error i.e calltransaction will be failure. Sy-subrc = 1001.
thanks
Manju.
‎2007 Jun 05 8:39 PM
Hi Manju Nagendra Beedam,
Then what can be done in this case...i mean how to make sy-subrc in Call Transaction to be 0.
Thanks
Dany
‎2007 Jun 06 8:05 AM
hi vijayd,
u just define one structute with bdcmsgcoll,
that structrue u can pass into call transaction ,
ie call trnasaction 'ft67' mode 'A' into <ur defined structure>.
then u can see your error messages in ur defined structure.
reward points if helpful,
regards,
seshu.
‎2007 Jun 06 6:04 PM
If you are not getting the error message then simply check sy-subrc to be 0 or not after call transaction
n give message with the text returned from the format_message fn module which is used to format the error message which you get after sending the error number to it.
‎2007 Jun 06 6:06 PM
Check this piece of code
FORM bdc_transaction tables return USING tcode p_rule.
*DATA : T_BDCMSGCOLL LIKE STANDARD TABLE OF BDCMSGCOLL WITH HEADER LINE.
CLEAR w_ctu_params.
w_ctu_params-dismode = 'N'.
w_ctu_params-updmode = 'S'.
w_ctu_params-cattmode = ' '.
w_ctu_params-defsize = ' '.
w_ctu_params-racommit = ' '.
w_ctu_params-nobinpt = 'X'.
w_ctu_params-nobiend = ' '.
CALL TRANSACTION tcode USING t_bdcdata OPTIONS FROM w_ctu_params
MESSAGES INTO t_bdcmsgcoll.
IF sy-subrc = 0.
IF p_rule = 'P'.
Add 1 to successful PWS creation
new_pws = new_pws + 1.
Add 1 to successful WSR creation
ELSEIF p_rule = 'W'.
new_wsr = new_wsr + 1.
ENDIF.
On successful WSR creation, create selection table for submit to
RPTSHF00 (to generate WSR)
IF new_wsr > 0.
PERFORM create_sel_tab.
ENDIF.
REFRESH t_bdcdata.
ELSE.
loop at t_bdcmsgcoll.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = t_bdcmsgcoll-msgid
LANG = SY-LANGU
NO = t_bdcmsgcoll-msgnr
V1 = t_bdcmsgcoll-MSGV1
V2 = t_bdcmsgcoll-MSGV2
V3 = t_bdcmsgcoll-MSGV3
V4 = t_bdcmsgcoll-MSGV4
IMPORTING
MSG = err_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.
move err_msg to w_return-message.
append w_return to return.
endloop.
ENDIF.
ENDFORM. " bdc_transaction