Thursday, March 26, 2009

Questions about INVOIC02 exits

Which user exits can be found in FI inbound processing of IDocs of category INVOIC01/02 and what can they be used for?
In the IDoc INVOIC01/02 how can you

    1. change the G/L account (BSEG-HKONT)?
    2. change the company code (BSEG-NEWBK)?
    3. fill or change the additional account assignments?
    4. fill the allocation number (BSEG-ZUONR)?
    5. fill the segment text (BSEG-SGTXT)?
    6. assign own names for the batch input sessions?
Other terms

EDI, IDOC_INPUT_INVOIC_FI, SAPLIEDI, OBCC, OBCE, OBCB, INVOIC01, INVOIC02, INVOIC, FEDI0001

Reason and Prerequisites
G/L account and company code
User exit 001

gives you the option of determining the G/L account and the company code for posting the delivery of goods/services.If no G/L account is determined, a corresponding exception can be triggered and a message generated as well. Up to and including Release 4.6C, you have to use the workaround described in note 330390 for the exceptions due to an error in the interface.
The exit is always called after an item segment was a processed completely and all of the data for this item is known (except for the additional account assignments and taxes).
The following data is available in the exit:
- the company code of this item
- the vendor account
- batch input fields and field contents of the current line item
Name of function module: EXIT_SAPLIEDI_001
The G/L account is determined from the settings in the Customizing Transaction OBCB by default.
The user exit cannot be used for changing the account assignment of any condition line items that may exist.For conditions, the account assignment is determined exclusively by means of the Customizing in OBCB.

Coding block
User exit 002

enables you to change the additional account assignments (COBL, coding block). When processing the line item data this is called directly after exit 001, but only if additional account assignments have already been made in the standard system or in exit 101.
As with 001 an exception and output of a message is supported here, too. (Up to and including Release 4.6C, take note 330390 into account.)
The following data is available in the exit:
- the company code of this item
- the vendor account
- date DATAB and DATBI
- batch input fields and field contents of the current line item
Name of function module: EXIT_SAPLIEDI_002
The additional account assignments are filled from the settings of the Customizing Transaction OBCC by default.

Allocation number
User exit 003

enables you to change the field BSEG-ZUONR (allocation number). As with 001 and 002 the exception NOT_FOUND can be triggered and a message generated as well. (Up to and including Release 4.6C, take note 330390 into account.)
The call is carried out after exit 002.
The following data is available in the exit:
- the company code of this item
- the vendor account
- batch input fields and field contents of the current line item
Name of function module: EXIT_SAPLIEDI_003
The allocation number is not filled as a default.

Segment text
User exit 004

enables you to set line item text (BSEG-SGTXT) for the G/L account lines. If a text is to be added for the vendor line item, you can use user exit 102. Exit 004 is called after exit 003 and has the same data and the same exception. (Up to and including Release 4.6C, take note 330390 into account.)
The following data is available in the exit:
- the company code of this item
- the vendor account
- batch input fields and field contents of the current line item
Name of function module: EXIT_SAPLIEDI_004
Only the first line of the segment text is transferred as a default.

Name of the batch input session
User exit 005

This exit is only relevant if you have set processing of the INVOIC01 IDocs for batch input sessions in the Customizing Transaction OBCE.These sessions receive a description as a default according to the schema: IV_ <Partner>. <Partner> is the name of the partner from the IDoc control record.
You are advised to distinguish the BDC sessions by using different names. You can do this with user exit 005.
The following data is available in the exit:
- the company code of this item
- the vendor account
Name of function module: EXIT_SAPLIEDI_005

Customer-defined segments and qualifiers
User exit 101

is called up for every segment after standard processing. Customer-defined segments can be processed this way.Furthermore, qualifiers that are not used in the standard system can be evaluated this way. In the case of incorrect specifications in the IDoc, a message can be generated. The message must be notified to the program in a structure FIMSG (see ABAP Dictionary). The messages are issued in the IDoc status record.A message of category E (Error) causes the IDoc to receive status 51 (incorrect).
The message is displayed in the status record of the IDoc.
The exit contains the following information:
- Control record information (in table IDOC_CONTRL)
- the index of the current IDoc in IDOC_CONTRL_INDEX (usually
  irrelevant, since at present the IDocs are always processed separately)
- the complete IDoc data (segment name, segment data in IDOC_DATA)
- the index of the segment processed currently (in IDOC_DATA_INDEX)
- the header and item data processed up to now for the call of
  transaction FB01 (in DOCUMENT_DATA)
- the tax data processed up to now (in TAX_DATA)
- the additional account assignments for CO, CO-PA and
  Business area (in ADDITIONAL_DATA) processed up to now
- the number of the currently processed line item (in DOCUMENT_LINE)

Procedure to process customer-defined segments or qualifiers:

    1. Call up segment name: IDOC_DATA-SEGNAM;
    2. place IDOC_DATA-SDATA in the structure related to the segment;
    3. evaluate data and append the result to the corresponding internal table (for example, DOCUMENT_DATA). The meaning of the fields:

STYPE: 'K' for document header data and 'P' for line item data
COUNT: Number of the item (is transferred in DOCUMENT_LINE)
FNAM : batch input name of the field to be appended (for example, 'COBL-KDPOS')
       The field name must be entered in upper case.
FVAL : required field contents

Name of function module: EXIT_SAPLIEDI_101

Change or check Posting data (complete document)
User exit 102

enables the validation and adjustment of the document data along the same lines as for user exit 101.However, it is called after all segments of the IDoc are read.At this point all data for the document is known. For the documents to be split, only the clearing lines are missing. For the vendor posting, item 1 is reserved. At this point it time, it is still incomplete. If you want to add data, that is not filled in the standard system (for example, the segment text), add the respective entry to table DOCUMENT_DATA.
An example for the segment text for the vendor line item:
STYPE = 'P', COUNT = 1, FNAM = 'BSEG-SGTXT', FVAL = <your text>

The exit contains the following information:
- Control record information (in table IDOC_CONTRL)
- the index of the current IDoc in IDOC_CONTRL_INDEX (usually
  irrelevant, since at present the IDocs are always processed separately)
- the complete IDoc data (segment name, segment data in IDOC_DATA)
- all header and item data for the document (except for vendor and
  clearing items (in DOCUMENT_DATA)
- all tax data (in TAX_DATA)
- all additional account assignments for CO, CO-PA and business area
  (in ADDITIONAL_DATA). Changes in this table, however,
  no longer have any effect on the document, since the processing of the
  items has already been completed.

Name of function module: EXIT_SAPLIEDI_102

You can obtain additional information from the documentation for the corresponding function module using Transaction SE37.
If you find the documentation does not exist in your own language, you should read Note 126192.



--
Ankur Bhandari.
SAP Consultant

Friday, March 20, 2009

Enable password saving in SAPLOGON shortcut

Standard SAP GUI doesn't allows to save password in the shortcuts. This can be achieved by doing these two steps.
1.) Executing sapshcut.exe which normally exists at C:\Program Files\SAP\FrontEnd\SAPgui.
Once this step is done then the variables which needs to be modified in REGEDIT are available for editing.
2.) Go to Command Prompt and type in REGEDIT -> HKEY_CURRENT_USER --> Software --> SAP --> SAPShortcut --> Security, Change the variable Enable Password from O to 1.
 
 
Regards,
Ankur Bhandari
 
 

Tuesday, March 17, 2009

sapnote_0000842318.pdf

Open the fields for Substitution GGB1

Many times Fields will not be readily available for Substitution like for example BKPD-BUDAT is not available for substitutuon but however if we need this field to be substituted. SAP provides a table which decides which field is available for substitution in GGB1. The table name is GB01 and the Maintenance view VWTYGB01 to remove the exclude field check can be achieved.
 
Regards,
Ankur Bhandari
 

Wednesday, March 04, 2009

ABAP Program to fix Released Transport tasks.

*&---------------------------------------------------------------------*
*& Report  YBAS_TRANS_FIX
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
 
REPORT  YBAS_TRANS_FIX.
 
* this program helps to fix some problems with tasks that have been
* released but are not setup correct.
* be carefull what you do and make shure you understand what the
* problem was, in the first place.
*
TABLES: TLOCK, E070, E070C, TDEVC.
PARAMETERS: CORRNR LIKE TLOCK-TRKORR.
parameters: newmand like sy-mandt.
PARAMETERS: NEWdev LIKE TADIR-DEVCLASS.
PARAMETERS: KNOWIT AS CHECKBOX.
PARAMETERS: TARdum AS CHECKBOX DEFAULT ' '.
PARAMETERS: CHTARCLI AS CHECKBOX DEFAULT ' '.
PARAMETERS: SRCCLI AS CHECKBOX DEFAULT ' '.
PARAMETERS: DELLOCK AS CHECKBOX DEFAULT ' '.
PARAMETERS: DISLOCK AS CHECKBOX DEFAULT ' '.
PARAMETERS: SETLOCA AS CHECKBOX DEFAULT ' '.
PARAMETERS: SETTRAN AS CHECKBOX DEFAULT ' '.
PARAMETERS: SETTRCP AS CHECKBOX DEFAULT ' '.
PARAMETERS: SETCORR AS CHECKBOX DEFAULT ' '.
PARAMETERS: SETREPA AS CHECKBOX DEFAULT ' '.
PARAMETERS: SETDEVC AS CHECKBOX DEFAULT ' '.
PARAMETERS: SETOWN  AS CHECKBOX DEFAULT ' '.
PARAMETERS: relcorr AS CHECKBOX DEFAULT ' '.
PARAMETERS: reltran AS CHECKBOX DEFAULT ' '.
 
IF KNOWIT <> 'X'.
   EXIT.
ENDIF.
IF DISLOCK = 'X'.
   SELECT * FROM TLOCK WHERE TRKORR = CORRNR.
   WRITE: / '* lock entry: ', TLOCK-OBJECT, TLOCK-TRKORR, TLOCK-AUTHOR .
   IF DELLOCK = 'X'.
     DELETE TLOCK.
   ENDIF.
   ENDSELECT.
ENDIF.
 
IF TARdum = 'X'.
   SELECT * FROM E070 WHERE TRKORR = CORRNR.
     WRITE: / '* e070 entry: ', E070.
     MOVE 'DUM' TO E070-TARSYSTEM.
     MODIFY E070.
     WRITE: / '* e070 entry: ', E070.
   ENDSELECT.
ENDIF.
 
IF CHTARCLI = 'X'.
  SELECT * FROM E070C WHERE TRKORR = CORRNR.
    WRITE: / '* e070C entry: ', E070C.
    MOVE newmand TO E070C-TARCLIENT.
    MODIFY E070C.
    WRITE: / '* e070C entry: ', E070C.
  ENDSELECT.
ENDIF.
 
IF SRCCLI = 'X'.
  SELECT * FROM E070C WHERE TRKORR = CORRNR.
    WRITE: / '* e070C entry: ', E070C.
    MOVE newmand TO E070C-CLIENT.
    MODIFY E070C.
    WRITE: / '* e070C entry: ', E070C.
  ENDSELECT.
ENDIF.
 
IF SETLOCA = 'X'.
  SELECT * FROM E070 WHERE TRKORR = CORRNR.
    WRITE: / '* e070 entry: ', E070.
    MOVE 'L' TO E070-TRFUNCTION.
    MOVE 'L' TO E070-TRSTATUS.
    MODIFY E070.
    WRITE: / '* e070 entry: ', E070.
  ENDSELECT.
ENDIF.
 
IF SETTRAN = 'X'.
  SELECT * FROM E070 WHERE TRKORR = CORRNR.
    WRITE: / '* e070 entry: ', E070.
    MOVE 'K' TO E070-TRFUNCTION.
    MOVE 'L' TO E070-TRSTATUS.
    MODIFY E070.
    WRITE: / '* e070 entry: ', E070.
  ENDSELECT.
ENDIF.
 
IF SETTRCP = 'X'.
  SELECT * FROM E070 WHERE TRKORR = CORRNR.
    WRITE: / '* e070 entry: ', E070.
    MOVE 'T' TO E070-TRFUNCTION.
    MOVE 'L' TO E070-TRSTATUS.
    MODIFY E070.
    WRITE: / '* e070 entry: ', E070.
  ENDSELECT.
ENDIF.
 
IF SETREPA = 'X'.
  SELECT * FROM E070 WHERE TRKORR = CORRNR.
    WRITE: / '* e070 entry: ', E070.
    MOVE 'R' TO E070-TRFUNCTION.
    MOVE 'D' TO E070-TRSTATUS.
    MODIFY E070.
    WRITE: / '* e070 entry: ', E070.
  ENDSELECT.
ENDIF.
 
IF SETCORR = 'X'.
  SELECT * FROM E070 WHERE TRKORR = CORRNR.
    WRITE: / '* e070 entry: ', E070.
    MOVE 'S' TO E070-TRFUNCTION.
    MOVE 'D' TO E070-TRSTATUS.
    MODIFY E070.
    WRITE: / '* e070 entry: ', E070.
  ENDSELECT.
ENDIF.
 
IF relcorr = 'X'.
  SELECT * FROM E070 WHERE TRKORR = CORRNR.
    WRITE: / '* e070 entry: ', E070.
    MOVE 'S' TO E070-TRFUNCTION.
    MOVE 'R' TO E070-TRSTATUS.
    MODIFY E070.
    WRITE: / '* e070 entry: ', E070.
  ENDSELECT.
ENDIF.
 
IF reltran = 'X'.
  SELECT * FROM E070 WHERE TRKORR = CORRNR.
    WRITE: / '* e070 entry: ', E070.
    MOVE 'K' TO E070-TRFUNCTION.
    MOVE 'R' TO E070-TRSTATUS.
    MODIFY E070.
    WRITE: / '* e070 entry: ', E070.
  ENDSELECT.
ENDIF.
 
 
 
* if setdevc = 'X'.
*  select * from tdevc where devclass = newdev.
*    write: / '* tdevc entry: ', tdevc.
*    move '   ' to tdevc-intsys.
*    move '   ' to tdevc-consys.
*    move '    '  to tdevc-pdevclass.
*    move ' '  to tdevc-korrflag.
*    modify tdevc.
*    write: / '* tdevc entry: ', tdevc.
*  endselect.
*  commit work.
* endif.
 
IF SETOWN = 'X'.
   SELECT * FROM E070 WHERE TRKORR = CORRNR.
     WRITE: / '* e070 entry: ', E070.
     MOVE SY-UNAME TO E070-AS4USER.
     MODIFY E070.
     WRITE: / '* e070 entry: ', E070.
   ENDSELECT.
ENDIF.
 
p.s: Courtesy Rene M for sharing this.

Monday, March 02, 2009

Usage and Benefits of Parallel Cursor in ABAP

Conventional Method
loop at lt_vbpa into wa_vbpa.  
loop at lt_kna1 into wa_kna1 where kunnr = wa_vbpa-kunnr.
****** Your Actual logic within inner loop ******
endloop.
endloop.
Parallel Cursor Method.
sort: lt_vbpa by kunnr, "Sorting by key is very important
lt_kna1 by kunnr. "Same key which is used for where condition is used here
loop at lt_vbpa into wa_vbpa.
read lt_kna1 into wa_kna1 " This sets the sy-tabix
with key kunnr = wa_vbpa-kunnr
binary search.
if sy-subrc = 0. "Does not enter the inner loop
v_kna1_index = sy-tabix.
loop at lt_kna1 into wa_kna1 from v_kna1_index. "Avoiding Where clause
if wa_kna1-kunnr <> wa_vbpa-kunnr. "This checks whether to exit out of loop
exit.
endif.

****** Your Actual logic within inner loop ******

endloop. "KNA1 Loop
endif.
endloop. " VBPA Loop
Regards,
Ankur Bhandari

Sunday, March 01, 2009

Avoid Log out and Log in after changes ...

Whenever any changes were made to the user authorizations, normally it is required to log-out
and log-in again to make these changes effective. Here is an alternative:

Execute the report RSUSR405 in SE38. This would refresh all user-related buffers and changes
to the authorizations are made effective immediately.

--
Ankur Bhandari.

iDoc special reports

1) RBDMANIN - Start Error Handling for Non-Posted IDocs

Description: This report attempts to post the inbound IDocs with status '51' (Application document not posted)

2) RBDAGAIN - Process Outbound IDocs with Errors Again

Description: This report reprocesses outbound IDocs which contain errors. IDocs containing errors have one of the following statuses:

  • 02: Error transmitting data to port
  • 04: Error in EDI subsystem control information
  • 05: Error in conversion
  • 25: Continue processing despite syntax error (outbound)
  • 29: Error in ALE service

3) RBDAGAIE - Reprocessing of Edited IDocs

Description: This report reprocesses an edited IDoc in inbound or outbound processing. The edited IDoc has one of the following statuses:

  • 32: IDoc edited (outbound)
  • 69: IDoc edited (inbound)

4) RBDAGAI2 - Re-processing of IDocs after ALE Input Error

Description: You use this report to reprocess inbound IDocs containing errors. IDocs containing errors have one of the following statuses:

  • 56: IDoc containing errors added
  • 61: Continue processing despite syntax error (inbox)
  • 63: Error passing IDoc to the application
  • 65: Error in ALE service

5) RBDAPP01 - Inbound Processing of IDocs Ready for Transfer

Description: Report for processing inbound IDocs not passed to the application immediately. This report forwards all IDocs with:

  • Status 64 "ready to be passed to application"
  • Status 66 "IDoc is waiting for predecessor IDoc (serialization)