2006 Feb 23 5:23 PM
Hi Experts,
This is Ram a newly joined forum recently and need some basic help please.
1) How to handle the errors in the BDC programming.
For example : One of the fields in between of the flat file(sourse data file) has incorrect format. Where do we handle them.
2) In SAPScripts what is the difference between the window and page-window. And i never understand what is the difference between
/: Address
/: Title &Title&
...
...
...
/: EndAddress
and
/: R1 (any test field)
&kna1-kunnr&
...
...
...
Thanks in Advance.
Ram
2006 Feb 23 5:44 PM
Hi Ram
in BDC there are two methods Session and cAll transaction.
for session method sap will automatically handle the error by displaying at the end of the BDC
for call transaction error handling has to be done for ex.
see the code
TABLES: T100.
Batch-input data
DATA: BEGIN OF G_BDCDATA OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF G_BDCDATA.
DATA: G_MESSAGE(200).
PERFORM FILL_BDCDATA.
CALL TRANSACTION 'FI01' USING G_BDCDATA MODE 'N'.
of course it is nicer with a message itab, but this example
should also demostrate the use of system variables.
SELECT SINGLE * FROM T100 WHERE
SPRSL = 'E'
AND ARBGB = SY-MSGID
AND MSGNR = SY-MSGNO.
G_MESSAGE = T100-TEXT.
PERFORM REPLACE_PARAMETERS USING SY-MSGV1
SY-MSGV2
SY-MSGV3
SY-MSGV4
CHANGING G_MESSAGE.
WRITE: / 'System variables:'.
SKIP.
WRITE: / ' Sy-msgty:', SY-MSGTY.
WRITE: / ' Sy-msgid:', SY-MSGID.
WRITE: / ' Sy-msgno:', SY-MSGNO.
WRITE: / ' Sy-msgv1:', SY-MSGV1.
WRITE: / ' Sy-msgv2:', SY-MSGV2.
WRITE: / ' Sy-msgv3:', SY-MSGV3.
WRITE: / ' Sy-msgv4:', SY-MSGV4.
SKIP.
WRITE: / 'The transaction was called with a wrong country code.'.
WRITE: / 'The error message should be either that or that you have'.
WRITE: / ' no authorisation to execute the transaction'.
SKIP.
WRITE: / 'Message:'.
SKIP.
WRITE: / SY-MSGTY, G_MESSAGE.
FORM REPLACE_PARAMETERS USING P_PAR_1
P_PAR_2
P_PAR_3
P_PAR_4
CHANGING P_MESSAGE.
erst mal pruefen, ob numerierte Parameter verwendet wurden
DO.
REPLACE '&1' WITH P_PAR_1 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&2' WITH P_PAR_2 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&3' WITH P_PAR_3 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&4' WITH P_PAR_4 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
falls keine numerierten Parameter vorh., ersetzen wie gehabt
REPLACE '&' WITH P_PAR_1 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_2 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_3 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_4 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "replace_parameters
regards
kishore
reward if helpful
2006 Feb 23 5:25 PM
If UR using CAll transaction then U need to pass
a structure to capture the messages of type BDCMSGCOLL
If U get an error get that record.
If UR using session method it will be automatically
handled
2006 Feb 23 5:30 PM
That was a quick response, Thanks for that.
Could you please give me a sample code for doing that so that i can do some RnD on that.
Ram
2006 Feb 23 5:33 PM
HI ram!
2) IN sap scripts.
window is the place where you create all the windows for example header address logo main footer and lots more
but you want header address logo in the first page and the main and footer in the second page. there comes the use of page windows.
page windows is the place where you will include the windows in the Page i.e for first page what are all the windows needed then for second page what are all the windows needed
hope you understood.
Address:
it is the address block where you will mention the address like number,city,location etc. it is predefiend by SAP just you have to pass the variable.
regards
kishore
Message was edited by: Harikishore Sreenivasulu
2006 Feb 23 5:57 PM
Thank you Hari and Srinivas for your help.
Now I need to do some RnD on these tomorrow.
I gave you some reward points to both.
Will ping you tomorror with new questions.
Thanks again
Ram
2006 Feb 23 5:44 PM
Hi Ram
in BDC there are two methods Session and cAll transaction.
for session method sap will automatically handle the error by displaying at the end of the BDC
for call transaction error handling has to be done for ex.
see the code
TABLES: T100.
Batch-input data
DATA: BEGIN OF G_BDCDATA OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF G_BDCDATA.
DATA: G_MESSAGE(200).
PERFORM FILL_BDCDATA.
CALL TRANSACTION 'FI01' USING G_BDCDATA MODE 'N'.
of course it is nicer with a message itab, but this example
should also demostrate the use of system variables.
SELECT SINGLE * FROM T100 WHERE
SPRSL = 'E'
AND ARBGB = SY-MSGID
AND MSGNR = SY-MSGNO.
G_MESSAGE = T100-TEXT.
PERFORM REPLACE_PARAMETERS USING SY-MSGV1
SY-MSGV2
SY-MSGV3
SY-MSGV4
CHANGING G_MESSAGE.
WRITE: / 'System variables:'.
SKIP.
WRITE: / ' Sy-msgty:', SY-MSGTY.
WRITE: / ' Sy-msgid:', SY-MSGID.
WRITE: / ' Sy-msgno:', SY-MSGNO.
WRITE: / ' Sy-msgv1:', SY-MSGV1.
WRITE: / ' Sy-msgv2:', SY-MSGV2.
WRITE: / ' Sy-msgv3:', SY-MSGV3.
WRITE: / ' Sy-msgv4:', SY-MSGV4.
SKIP.
WRITE: / 'The transaction was called with a wrong country code.'.
WRITE: / 'The error message should be either that or that you have'.
WRITE: / ' no authorisation to execute the transaction'.
SKIP.
WRITE: / 'Message:'.
SKIP.
WRITE: / SY-MSGTY, G_MESSAGE.
FORM REPLACE_PARAMETERS USING P_PAR_1
P_PAR_2
P_PAR_3
P_PAR_4
CHANGING P_MESSAGE.
erst mal pruefen, ob numerierte Parameter verwendet wurden
DO.
REPLACE '&1' WITH P_PAR_1 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&2' WITH P_PAR_2 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&3' WITH P_PAR_3 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&4' WITH P_PAR_4 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
falls keine numerierten Parameter vorh., ersetzen wie gehabt
REPLACE '&' WITH P_PAR_1 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_2 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_3 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_4 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "replace_parameters
regards
kishore
reward if helpful