‎2008 Jun 09 8:02 AM
i have a flat file with 10 records. in that if 4th record is error record.
how many records are going to updated in the db using call transaction and session?
i worked on above problem i came to know that except error record all the remaining records are updated in db using call transaction and session.
then what is difference between synchronous update and asynchronous update?
‎2008 Jun 09 9:47 AM
Hi Rao,
The difference between synchronous update and asynchronous update is
Asynchronous Update The program does not wait for the work process to finish the update.
Commit Work.
Synchronous Update The program wait for the work process to finish the update. Commit Work and Wait.
You should write the error code to catch the expceptions in call transaction method. Only 3 records will get updated in call transaction it will show error on 4th record and will not get updated.
Session method.
1) synchronous processing.
2) can tranfer large amount of data.
3) processing is slower.
4) error log is created
5) data is not updated until session is processed.
Call transaction.
1) asynchronous processing
2) can transfer small amount of data
3) processing is faster.
4) errors need to be handled explicitly
5) data is updated automatically
Reward Points if useful.
Warm Regards
Gokul
‎2008 Jun 09 11:43 AM
hi gokul,
check this code.
TYPES : BEGIN OF tw_kna1,
kunnr TYPE kunnr,
ktokd TYPE ktokd,
name1 TYPE name1,
sortl TYPE sortl,
stras TYPE stras,
land1 TYPE land1,
spras TYPE spras,
END OF tw_kna1,
tt_kna1 TYPE STANDARD TABLE OF tw_kna1.
DATA : lw_kna1 TYPE tw_kna1,
lt_kna1 TYPE tt_kna1.
DATA : lw_bdcdata TYPE bdcdata,
lt_bdcdata TYPE STANDARD TABLE OF bdcdata.
DATA : lw_bdcmsgcoll TYPE bdcmsgcoll,
lt_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll.
DATA : lf_fpath TYPE string.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : pa_fpath TYPE localfile.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_fpath.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = pa_fpath.
START-OF-SELECTION.
lf_fpath = pa_fpath.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lf_fpath
filetype = 'ASC'
has_field_separator = 'X'
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 = lt_kna1
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.
IF sy-subrc EQ 0.
LOOP AT lt_kna1 INTO lw_kna1.
PERFORM bdc_dynpro USING 'SAPMF02D' '0107'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02D-KTOKD'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02D-KUNNR'
lw_kna1-kunnr.
PERFORM bdc_field USING 'RF02D-KTOKD'
lw_kna1-ktokd.
PERFORM bdc_dynpro USING 'SAPMF02D' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'KNA1-SPRAS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPDA'.
PERFORM bdc_field USING 'KNA1-NAME1'
lw_kna1-name1.
PERFORM bdc_field USING 'KNA1-SORTL'
lw_kna1-sortl.
PERFORM bdc_field USING 'KNA1-STRAS'
lw_kna1-stras.
PERFORM bdc_field USING 'KNA1-LAND1'
lw_kna1-land1.
PERFORM bdc_field USING 'KNA1-SPRAS'
lw_kna1-spras.
CALL TRANSACTION 'VD01' USING lt_bdcdata
MODE 'N' UPDATE 'S'
MESSAGES INTO lt_bdcmsgcoll.
REFRESH LT_BDCDATA.
CLEAR LW_BDCDATA.
ENDLOOP.
PERFORM fr_display_log.
ENDIF.
&----
*& Form bdc_dynpro
&----
text
----
-->P_0165 text
-->P_0166 text
----
FORM bdc_dynpro USING value(uf_program)
value(uf_dynpro).
CLEAR lw_bdcdata.
lw_bdcdata-program = uf_program.
lw_bdcdata-dynpro = uf_dynpro.
lw_bdcdata-dynbegin = 'X'.
APPEND lw_bdcdata TO lt_bdcdata.
ENDFORM. " bdc_dynpro
&----
*& Form bdc_field
&----
text
----
-->P_0170 text
-->P_0171 text
----
FORM bdc_field USING value(uf_fnam)
value(uf_fval).
CLEAR lw_bdcdata.
lw_bdcdata-fnam = uf_fnam.
lw_bdcdata-fval = uf_fval.
APPEND lw_bdcdata TO lt_bdcdata.
ENDFORM. " bdc_field
&----
*& Form fr_display_log
&----
text
----
--> p1 text
<-- p2 text
----
FORM fr_display_log .
DATA: lf_message TYPE string.
LOOP AT lt_bdcmsgcoll INTO lw_bdcmsgcoll.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = sy-msgid
lang = sy-langu
no = lw_bdcmsgcoll-msgnr
v1 = lw_bdcmsgcoll-msgv1
v2 = lw_bdcmsgcoll-msgv2
v3 = lw_bdcmsgcoll-msgv3
v4 = lw_bdcmsgcoll-msgv4
IMPORTING
msg = lf_message
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.
WRITE:/ LW_BDCMSGCOLL-MSGID,
LW_BDCMSGCOLL-MSGNR,
LF_MESSAGE.
ENDLOOP.
ENDFORM. " fr_display_log
flat file structure:
48 0004 XXS XU QQQUU IN EN
dd 0004 XXS XU QQQUU IN EN (error record)
49 0004 XTU XV RRRVV IN EN
as per your answer as the second record is error record, third record must not be updated in db.
but when i upload this flat file the third record also updated in db.
‎2008 Jun 09 12:26 PM
Hi Raja,
Pls go thru once again through the explanation of Gokul. He has clearly explained the same. But let me clear you again.
The Transaction is being called for each and every record of your flat file. That means, the internal table will have all the records from your flat file. And the records which are not processed will not have any effect on the other records, the Transaction will try committing (LOOP AT ITAB) for each record from the internal table, regardless of the type of Update Mode (Synchronous or Asynchronous).
As per your example Flat File, if the 2nd record has got error then also the third record will be processed (LOOP AT ITAB) and the error log is updated to it_bdcmsgcoll table. And the third record, if correct, will get updated to the database.
Thanks,
-Syed.
‎2008 Jun 09 9:55 AM
Hi,
Gokul has explained very well the definitions of call transaction batch input session,synchronous update and asynchronous update.
However, the way your 10 records are processed has nothing to do with synchronous or asychronous update. The nine file records that are processed each are a complete transaction that can be posted independently of the others. They may or may not post synchronously, the concept has nothing to do with call transaction.
Regards,
Nick