Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

bdc error manageing

Former Member
0 Likes
576

hi '

need a little solution ,

iam doing a bdc of z transaction and need help

well i have to check the iinput with amounts

if user input amount suppose 10,000 , and after if the amonut is break into

suppose 2000,3000 4000 for same bill number and its should be equal to 1000 then

only the bdc has to perform other wise the requirement is it should store the

error(how to store in itab by appending or) into a error file and should not perform the bdc and very importnat that

error record should delete from internal table ...iam new so need help

pls

i will be thankfull if get a sample code.

regards.

the code

data: begin of itab occurs 0 ,

trtyp like ztrlr-trtyp,

trptr like ztrlr-trptr,

gjhar like ztrlr-gjhar,

billdat like ztrlr-billdat,

bilmat like ztrlr-bilmat,

lrno like ztrlr-lrno,

lramt like ztrpaybrk-lramt,

end of itab.

data: itab2 like itab occurs 0 with header line. "to store error records.

PARAMETERS : p_fname LIKE ibipparms-path OBLIGATORY.

include bdcrecx1.

start-of-selection.

perform open_group.

perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0001'.

perform bdc_field using 'BDC_OKCODE'

'=ENT'.

perform bdc_field using 'BDC_CURSOR'

'ZTRBILL-BILAMT'.

perform bdc_field using 'ZTRLR-TRTYP'

'N'.

perform bdc_field using 'ZTRLR-TRPTR'

'0000900036'.

perform bdc_field using 'ZTRLR-GJAHR'

'2004'.

perform bdc_field using 'ZTRBILL-BILNR'

'123456789'.

perform bdc_field using 'ZTRBILL-BILLDAT'

'08022006'.

perform bdc_field using 'ZTRBILL-BILAMT'

'10000'.

perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0002'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'ZTR_VIEW_LRAMT-LRAMT(14)'.

perform bdc_field using 'ZTR_VIEW_LRAMT-LRAMT(01)'

'2500'.

perform bdc_field using 'ZTR_VIEW_LRAMT-LRAMT(02)'

'2500'.

perform bdc_field using 'ZTR_VIEW_LRAMT-LRAMT(03)'

'2500'.

perform bdc_field using 'ZTR_VIEW_LRAMT-LRAMT(04)'

'2500'.

perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0002'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BDC_CURSOR'

'ZTRLR-TRTYP'.

perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0002'.

perform bdc_field using 'BDC_OKCODE'

'=SAVE'.

perform bdc_field using 'BDC_CURSOR'

'ZTRLR-TRTYP'.

perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0001'.

perform bdc_field using 'BDC_OKCODE'

'/EEXIT'.

perform bdc_field using 'BDC_CURSOR'

'ZTRLR-TRTYP'.

perform bdc_transaction using 'ZTRBILL'.

perform close_group.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
541

"Check the data

perform bdc_transaction using 'FI01' changing err rc.

write:/ 'after calling transaction : rc ',rc,'   err ',err.

if rc <> 0.
    append record to erroritab.
endif.

"At your LOOP ... ENDLOOP

LOOP AT itab.
 IF err = 1.
   DELETE itab from itab.
 ENDIF.
ENDLOOP.

3 REPLIES 3
Read only

Former Member
0 Likes
542

"Check the data

perform bdc_transaction using 'FI01' changing err rc.

write:/ 'after calling transaction : rc ',rc,'   err ',err.

if rc <> 0.
    append record to erroritab.
endif.

"At your LOOP ... ENDLOOP

LOOP AT itab.
 IF err = 1.
   DELETE itab from itab.
 ENDIF.
ENDLOOP.

Read only

Former Member
0 Likes
541

I think you can modify the include in the following way to include the of your BDC program...

this ia a modification made to the include bdcrecx1..

this code transfeers all the error msgs to an internal table..ERROR_ITAB

&----


& Include YINCLUDE

&----


----


  • data definition

----


  • Batchinputdata of single transaction

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

  • messages of call transaction

DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

  • error session opened (' ' or 'X')

DATA: E_GROUP_OPENED.

  • message texts

TABLES: T100 , crhd.

data : itab_crhd like table of crhd with header line.

DATA : NODATA VALUE '/',

CTUMODE LIKE CTU_PARAMS-DISMODE VALUE 'N',

CUPDATE LIKE CTU_PARAMS-UPDMODE VALUE 'L'.

DATA : ERR TYPE STRING.

DATA : RC TYPE I,

successcnt type i value 0,

failcount type i value 0.

data : cntr type i value 0.

AT SELECTION-SCREEN.

FORM OPEN_DATASET USING P_DATASET.

OPEN DATASET P_DATASET

FOR INPUT IN TEXT MODE

ENCODING DEFAULT.

IF SY-SUBRC <> 0.

WRITE: / TEXT-E00, SY-SUBRC.

STOP.

ENDIF.

ENDFORM.

FORM CLOSE_DATASET USING P_DATASET.

CLOSE DATASET P_DATASET.

ENDFORM.

FORM BDC_TRANSACTION USING TCODE .

DATA: L_MSTRING(480).

DATA : BEGIN OF ERROR_ITAB OCCURS 0,

ERROR(50),

MSGTYP,

END OF ERROR_ITAB.

DATA : WA LIKE LINE OF ERROR_ITAB.

DATA: L_SUBRC LIKE SY-SUBRC.

REFRESH MESSTAB.

CALL TRANSACTION TCODE USING BDCDATA

MODE 'N'

UPDATE 'L'

MESSAGES INTO MESSTAB.

L_SUBRC = SY-SUBRC.

LOOP AT MESSTAB.

if messtab-msgtyp eq 'E'.

SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA

AND ARBGB = MESSTAB-MSGID

AND MSGNR = MESSTAB-MSGNR.

IF SY-SUBRC = 0.

L_MSTRING = T100-TEXT.

IF L_MSTRING CS '&1'.

REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ELSE.

REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.

REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.

ENDIF.

CONDENSE L_MSTRING.

MOVE L_MSTRING TO ERROR_ITAB-ERROR.

MOVE MESSTAB-MSGTYP TO ERROR_ITAB-MSGTYP.

APPEND ERROR_ITAB.

  • delete error_itab where msgtyp = 'S'.

ELSE.

MOVE MESSTAB TO ERROR_ITAB-ERROR.

APPEND ERROR_ITAB.

ENDIF.

clear itab_crhd.

refresh itab_crhd.

Read only

Former Member
0 Likes
541

A little modification of your code to suit your needs. Reply if more help is needed.


data: begin of itab occurs 0 , 
trtyp like ztrlr-trtyp,
trptr like ztrlr-trptr,
gjhar like ztrlr-gjhar,
billdat like ztrlr-billdat,
bilmat like ztrlr-bilmat,
lrno like ztrlr-lrno,
lramt like ztrpaybrk-lramt,
end of itab.

data: itab2 like itab occurs 0 with header line. "to store error records.






PARAMETERS : p_fname LIKE ibipparms-path OBLIGATORY.

include bdcrecx1.

start-of-selection.

perform open_group.

<b>loop at itab.</b>
perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0001'.
perform bdc_field using 'BDC_OKCODE'
'=ENT'.
perform bdc_field using 'BDC_CURSOR'
'ZTRBILL-BILAMT'.
perform bdc_field using 'ZTRLR-TRTYP'
'N'.
perform bdc_field using 'ZTRLR-TRPTR'
'0000900036'.
perform bdc_field using 'ZTRLR-GJAHR'
'2004'.
perform bdc_field using 'ZTRBILL-BILNR'
'123456789'.
perform bdc_field using 'ZTRBILL-BILLDAT'
'08022006'.
perform bdc_field using 'ZTRBILL-BILAMT'
'10000'.
perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0002'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'ZTR_VIEW_LRAMT-LRAMT(14)'.
perform bdc_field using 'ZTR_VIEW_LRAMT-LRAMT(01)'
'2500'.
perform bdc_field using 'ZTR_VIEW_LRAMT-LRAMT(02)'
'2500'.
perform bdc_field using 'ZTR_VIEW_LRAMT-LRAMT(03)'
'2500'.
perform bdc_field using 'ZTR_VIEW_LRAMT-LRAMT(04)'
'2500'.
perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0002'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'ZTRLR-TRTYP'.
perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0002'.
perform bdc_field using 'BDC_OKCODE'
'=SAVE'.
perform bdc_field using 'BDC_CURSOR'
'ZTRLR-TRTYP'.
perform bdc_dynpro using 'ZTR_MP_LR_ASSIGN' '0001'.
perform bdc_field using 'BDC_OKCODE'
'/EEXIT'.
perform bdc_field using 'BDC_CURSOR'
'ZTRLR-TRTYP'.
perform bdc_transaction using 'ZTRBILL'.
<b>if rc <> 0.
  append itab to itab2.
  delete itab.
ENDIF.
endloop.</b>perform close_group.

Message was edited by: Wenceslaus G