2015 Feb 10 5:42 AM
Hi Experts,
I have report program to change the referance field value in Transaction code - FB02 using function module FI_DOCUMENT_CHANGE but thing is there we will run this report in background job,So at that time if any error message will through that function module then how to i will maintain that error in error log.Anyone can help me on requirement.
Thanks
2015 Feb 10 5:58 AM
Hi Ram,
You can define an internal table for storing the errors and exception. You can fill that internal table by checking the sy-subrc after the function is executed. The sy-subrc field will return the value referring to exception.
For eg.
NO_REFERENCE = 1
NO_DOCUMENT = 2
MANY_DOCUMENTS = 3
WRONG_INPUT = 4
OVERWRITE_CREDITCARD = 5
OTHERS = 6.
depending on the value stored in sy-subrc write a logic in CASE.. ENDCASE block and fill the internal table accordingly.
Hope this will help you.
Hi Experts,
I have report program to change the referance field value in Transaction code - FB02 using function module FI_DOCUMENT_CHANGE but thing is there we will run this report in background job,So at that time if any error message will through that function module then how to i will maintain that error in error log.Anyone can help me on requirement.
Thanks
2015 Feb 10 5:51 AM
Hi,
You can generate one simple ALV report with list of exceptions occcured if any. So when ever an exception occurs, the list of exceptions can be seen in your ALV report which is generated if your program runs in background.
Ex :
CALL FUNCTION 'FI_DOCUMENT_CHANGE'
* EXPORTING
* I_AWTYP =
* I_AWREF =
* I_AWORG = ' '
* I_AWSYS = ' '
* I_KUNNR = ' '
* I_LIFNR = ' '
* I_OBZEI = ' '
* I_BUZEI =
* I_BSEGC =
* X_LOCK = 'X'
* I_BUKRS =
* I_BELNR =
* I_GJAHR =
TABLES
t_accchg =
* EXCEPTIONS
* NO_REFERENCE = 1
* NO_DOCUMENT = 2
* MANY_DOCUMENTS = 3
* WRONG_INPUT = 4
* OVERWRITE_CREDITCARD = 5
* OTHERS = 6
.
IF sy-subrc <> 0.
"catch the exception here and update your execption itab(which needs to be created) and finally show the exceptions itab in your ALV report.
ENDIF.
Hope this helps you.
Thanks
KH
2015 Feb 10 5:51 AM
Hi,
You can generate one simple ALV report with list of exceptions occcured if any. So when ever an exception occurs, the list of exceptions can be seen in your ALV report which is generated if your program runs in background.
Ex :
CALL FUNCTION 'FI_DOCUMENT_CHANGE'
* EXPORTING
* I_AWTYP =
* I_AWREF =
* I_AWORG = ' '
* I_AWSYS = ' '
* I_KUNNR = ' '
* I_LIFNR = ' '
* I_OBZEI = ' '
* I_BUZEI =
* I_BSEGC =
* X_LOCK = 'X'
* I_BUKRS =
* I_BELNR =
* I_GJAHR =
TABLES
t_accchg =
* EXCEPTIONS
* NO_REFERENCE = 1
* NO_DOCUMENT = 2
* MANY_DOCUMENTS = 3
* WRONG_INPUT = 4
* OVERWRITE_CREDITCARD = 5
* OTHERS = 6
.
IF sy-subrc <> 0.
"catch the exception here and update your execption itab(which needs to be created) and finally show the exceptions itab in your ALV report.
ENDIF.
Hope this helps you.
Thanks
KH
2015 Feb 10 5:58 AM
Hi Ram,
You can define an internal table for storing the errors and exception. You can fill that internal table by checking the sy-subrc after the function is executed. The sy-subrc field will return the value referring to exception.
For eg.
NO_REFERENCE = 1
NO_DOCUMENT = 2
MANY_DOCUMENTS = 3
WRONG_INPUT = 4
OVERWRITE_CREDITCARD = 5
OTHERS = 6.
depending on the value stored in sy-subrc write a logic in CASE.. ENDCASE block and fill the internal table accordingly.
Hope this will help you.
2015 Feb 10 6:15 AM
Hi Sneha,
Can you briefly explain me about of this my requirement and if possibilities with any sample logic.Canm you provide me.
Thanks,
2015 Feb 10 6:33 AM
Hi Ram,
Define 1 internal table with below structure:
types:
begin of ty_error,
errorid type n,
errortext(50) type c, "you can also add some of the key fields of records which you are " changing
end of ty_error.
Data: it_error type table of ty_error,
wa_error type table of ty_error.
now after the FM gets executes write following piece of code:
CALL FUNCTION 'FI_DOCUMENT_CHANGE'
EXPORTING
i_awtyp =
i_awref =
i_aworg =
i_kunnr =
TABLES
it_accchg = it_accchg
EXCEPTIONS
NO_REFERENCE = 1
NO_DOCUMENT =
MANY_DOCUMENTS = 3
WRONG_INPUT = 4
OVERWRITE_CREDITCARD = 5
OTHERS = 6.
if sy-subrc <> 0.
data: lv_subrc type sy-subrc.
lv_subrc = sy-subrc.
Case lv_subrc:
when 1.
wa_error-errorid = lv_subrc.
wa_error-errortext = 'Description of the error'.
when 2.
.
.
.
Endcase.
Append this work area to it_error table.
Now you are having all the error records in it_error table.
Now just write a logic for display the ALV report on table it_error.
As you are running this report in background you can see the alv report in spool. Using TCODE Sp01.
2015 Feb 10 6:15 AM
Hello,
You can handle the exception and display the message as:
CALL FUNCTION 'FI_DOCUMENT_CHANGE'
EXPORTING
i_awtyp =
i_awref =
i_aworg =
i_kunnr =
TABLES
it_accchg = it_accchg
EXCEPTIONS
no_reference = 1
no_documents = 1
many_documents = 1
wrong_input = 4
overwrite_creditcard = 5
OTHERS = 6.
if sy-subrc <> 0.
MESSAGE ID sy-msgid type sy-msgty NUMBER sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif,
When exception occurs message will be displayed.
Reward if useful.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |