10-11-2007 11:58 AM
10-11-2007 11:59 AM
you can use call transaction method to upload data into transaction using BDC....
and if the call transaction fails ( sy-subrc <> 0 ) then use session method to capture errors...
*************************************
see example.....in my program i used like this...
LOOP AT it_0019 INTO wa_0019.
CLEAR: it_bdcdata,it_bdcmsgcoll.
REFRESH:it_bdcdata,it_bdcmsgcoll.
CLEAR: lv_begda,lv_endda,lv_termn,lv_termn1, lv_mndat.
*--Authorization checks
CLEAR:l_tabix , gv_subrc , gv_infty.
l_tabix = sy-tabix.
CLEAR it_auth.
it_auth-infty = '0019'.
it_auth-subty = wa_0019-subty.
APPEND it_auth.
CLEAR it_auth.
PERFORM check_authority TABLES it_auth
USING wa_0019-pernr
CHANGING gv_subrc
gv_infty.
DELETE it_auth WHERE infty = '0019'.
IF gv_subrc NE 0.
gv_rej = gv_rej + 1.
it_auth_fail-pernr = wa_0019-pernr.
it_auth_fail-infty = gv_infty.
IF gv_infty = '0019'.
it_auth_fail-subty = wa_0019-subty.
ENDIF.
APPEND it_auth_fail.
CLEAR it_auth_fail.
DELETE it_0019 INDEX l_tabix.
CONTINUE.
ENDIF.
WRITE wa_0019-begda TO lv_begda.
WRITE wa_0019-endda TO lv_endda.
WRITE wa_0019-termn TO lv_termn1.
*--Setting date of task to date which is 1 year ahead
wa_0019-termn0(4) = wa_0019-termn0(4) + 1.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = wa_0019-termn
days = 0
months = 0
SIGNUM = '+'
years = 1
IMPORTING
calc_date = wa_0019-termn.
*--Setting reminder date to date 1 year ahead
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = wa_0019-mndat
days = 0
months = 0
SIGNUM = '+'
years = 1
IMPORTING
calc_date = wa_0019-mndat.
WRITE wa_0019-mndat TO lv_mndat.
WRITE wa_0019-termn TO lv_termn.
*--Getting list of records for pernr in date range
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=LIST'.
PERFORM bdc_field USING 'RP50G-PERNR'
wa_0019-pernr.
PERFORM bdc_field USING 'RP50G-TIMR6'
'X'.
PERFORM bdc_field USING 'RP50G-BEGDA'
lv_begda.
PERFORM bdc_field USING 'RP50G-ENDDA'
lv_endda.
PERFORM bdc_field USING 'RP50G-CHOIC'
'0019'.
PERFORM bdc_field USING 'RP50G-SUBTY'
wa_0019-subty.
*--Processing records by selecting record
PERFORM bdc_dynpro USING 'MP001900' '3000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RP50M-BEGDA'
lv_termn1.
PERFORM bdc_field USING 'RP50M-ENDDA'
lv_termn1.
PERFORM bdc_field USING 'RP50M-SUBTY'
wa_0019-subty.
PERFORM bdc_field USING 'RP50M-PAGEA'
' 1'.
*--Copying the record
PERFORM bdc_dynpro USING 'MP001900' '3000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=COP'.
PERFORM bdc_field USING 'RP50M-BEGDA'
lv_termn1.
PERFORM bdc_field USING 'RP50M-ENDDA'
lv_termn1.
PERFORM bdc_field USING 'RP50M-SUBTY'
wa_0019-subty.
PERFORM bdc_field USING 'RP50M-PAGEA'
' 1'.
PERFORM bdc_field USING 'RP50M-SELE2(01)'
'X'.
*--Modifying required fields
PERFORM bdc_dynpro USING 'MP001900' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
PERFORM bdc_field USING 'P0019-TERMN'
lv_termn.
PERFORM bdc_field USING 'P0019-MNDAT'
lv_mndat.
PERFORM bdc_dynpro USING 'MP001900' '3000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/EBCK'.
CALL TRANSACTION 'PA30' USING it_bdcdata
MODE 'N'
UPDATE 'S'
MESSAGES INTO it_bdcmsgcoll.
IF sy-subrc = 0.
*--- Successful records
gv_updated = gv_updated + 1.
ELSE.
**--- Rejected records
IF gv_open IS INITIAL.
**--- Open the session to process error records
PERFORM bdc_open_group.
gv_open = 'X'.
ENDIF.
**--- Insert the records
PERFORM bdc_insert.
**--- Collect Error records
PERFORM error_records.
gv_rej = gv_rej + 1.
ENDIF.
ENDLOOP.
IF gv_open = 'X'.
*--- Close the session
PERFORM bdc_close_group.
ENDIF.
*FORM bdc_open_group.
**--- Open the session
*CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
GROUP =
HOLDDATE = sy-datum
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.
IF sy-batch <> 'X'.
MESSAGE i000(zz) WITH 'Unable to open the Session'(005).
ELSE.
WRITE:/ 'Unable to open the Session'(005).
ENDIF.
ENDIF.
*ENDFORM. " bdc_open_group
*FORM bdc_close_group.
**-- To close the session
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
IF sy-batch <> 'X'.
MESSAGE i000(zz) WITH 'Unable to close the session'(012).
ELSE.
WRITE:/ 'Unable to close the session'(012).
ENDIF.
ENDIF.
*ENDFORM. " bdc_close_group
&----
*& Form error_records
&----
text
----
--> p1 text
<-- p2 text
----
FORM error_records.
CLEAR gv_message.
CLEAR sy-tfill.
DESCRIBE TABLE it_bdcmsgcoll LINES sy-tfill.
READ TABLE it_bdcmsgcoll INDEX sy-tfill.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = it_bdcmsgcoll-msgid
lang = sy-langu
no = it_bdcmsgcoll-msgnr
v1 = it_bdcmsgcoll-msgv1
v2 = it_bdcmsgcoll-msgv2
v3 = it_bdcmsgcoll-msgv3
v4 = it_bdcmsgcoll-msgv4
IMPORTING
msg = gv_message
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
it_bdc_fail-pernr = wa_0019-pernr.
it_bdc_fail-message = gv_message.
APPEND it_bdc_fail.
CLEAR it_bdc_fail.
CLEAR gv_message.
ENDIF.
ENDFORM. " error_records
*FORM bdc_insert.
**--- Insert the records into session
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = 'PA30'
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.
IF sy-batch <> 'X'.
MESSAGE i000(zz) WITH 'Unable to insert data into BDC session'(019)
*.
ELSE.
WRITE:/ 'Unable to insert data into BDC session'(019).
ENDIF.
ENDIF.
*ENDFORM. " bdc_insert
Regards
Vasu
10-11-2007 12:00 PM
Hi Jyothsna.
Yes .. We can use..
Scenario:
Use the Call transaction statement to Update the Data.
Create a Session that stores all the ERROR transactions. So that we can process this Session in ERRORS ONLY mode later.
REWARD IF HELPFUL.
10-11-2007 12:02 PM
YES U CAN DO THAT
BY USING RECORDING (SHDB)
BUT U HAVE TO PROCESS THE TCODE EITHER BY USE SESSION OR CALL TRANSACTION.
REWARD IF U FIND USEFUL
REGARDS
NAGESH.PARUCHURI
10-11-2007 12:06 PM
HI
yes both session and call transaction can be writen in one program
in the output screen there should be 2 radiobuutons just we need to select session or call transaction at that time
if you want the program then
after recording the T-code in SHDB
just goto the session overview there on application tool bar you will find one button PROGRAM
click on that program it will ask you to save that program with some name
after that execute that program
you can see that session and call transaction programs there
<b>Reward if usefull</b>