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

Bapi BAPI_INCOMINGINVOICE_PARK

Former Member
8,534

Hi all,

I know this question has been asked before many years ago but we are trying to use BAPI BAPI_INCOMINGINVOICE_PARK to park invoice but we get the error :

Enter goods receipt data only when working with GR-based IV

Enter a reference to a valid goods receipt (line 000001)

This is not appropriate for these PO's, infact MIR7 deals with this situation by quite happily parking them using MRM_INVOICE_PARK. Unfortunately BAPI_INCOMINGINVOICE_PARK specifically catches this situation and raises an error:

*----- ... GR based IV, but no GR data in invoice item ---------------*
*----- ... (exception: service PO needs entry sheet number) ----------*
  IF (     i_itemdata-ref_doc        IS INITIAL
        OR i_itemdata-ref_doc_year   IS INITIAL
        OR i_itemdata-ref_doc_it     IS INITIAL )
       AND NOT i_ekpo-webre IS INITIAL
       AND NOT i_ekpo-pstyp = c_pstyp_9
       AND i_itemdata-cond_type  IS INITIAL
       AND i_itemdata-cond_st_no IS INITIAL
       AND i_itemdata-cond_count IS INITIAL.
e_subrc = 4.

Even if i stop this happening and bypass this 'IF' the BAPI still comes unstuck when it gets to the end and calls MRM_INVOICE_CREATE to park it, this also does a similar check and causes a similar error failing to park. I thought the whole point of BAPI's is that they mimic standard SAP functionality which this clearly does not, does anyone know if there is a reason it is like this? and if there is an alternative to BAPI_INCOMINGINVOICE_PARK which will work like MIR7 and just use MRM_INVOICE_PARK rather than MRM_INVOICE_CREATE to process these PO's

Any help would be much appreciated

Regards

Mart

22 REPLIES 22
Read only

former_member182371
Active Contributor
0 Likes
6,809

Hi,

have you tried unticking "GR-Based IV" in ME22N (Item, Invoice tab)?

thus you would have -> i_ekpo-webre EQ INITIAL.

Best regards.

Read only

0 Likes
6,809

>

> have you tried unticking "GR-Based IV" in ME22N (Item, Invoice tab)?

> thus you would have -> i_ekpo-webre EQ INITIAL.

> Best regards.

As far as I can see, That seems to be the best option available...

Pablo, by Unchecking this GR Based IV, wouldn't there be a risk that Users can post the invoice successfully? If that is the case, does the user need to check this flag on PO Item, once parked invoice is posted?

Read only

0 Likes
6,809

Unfortunately that is not really possible as these PO's are set by the bussiness like this for a reason, also the BAPI is being called remotly so could proccess any PO which may or may not have the i_ekpo-webre value set and even if it is set it may or may not already have a GR document created. I guess i could enhance the bapi/create z version to update the table and remove the flag just while it parks it and then put it back on afterwards, but i do not really know enough about this process to appreciate what problems could arrise. Another option would be to do a BDC recording of MIR7 and then get the BAPI to execute that! Either way its not ideal:-( Seems strange that SAP would just not allow these PO's to be proccessed via this BAPI!

Regards

Mart

Read only

0 Likes
6,809

Hi,

we get the error :

Enter goods receipt data only when working with GR-based IV

Enter a reference to a valid goods receipt (line 000001)

1.- The first message is message M8 376

This message can be raised in three places:

1.1.-


*----- ... no GR based IV, but GR data in invoice item ---------------*
  IF NOT (     i_itemdata-ref_doc        IS INITIAL
           AND i_itemdata-ref_doc_year   IS INITIAL
           AND i_itemdata-ref_doc_it     IS INITIAL
           AND i_itemdata-sheet_no       IS INITIAL )
         AND i_ekpo-webre IS INITIAL.
    e_subrc = 4.
    PERFORM bapireturn_fill USING  'M8'
                                   'E'
                                   '376'
                                   i_itemdata-invoice_doc_item
                                   i_itemdata-po_number
                                   i_itemdata-po_item
                                   space
                          CHANGING te_return.
  ENDIF.

This means that you´re informing values in:

i_itemdata-ref_doc

i_itemdata-ref_doc_year

i_itemdata-ref_doc_it

but you´re not using GR Based IV.

1.2.-


*----- ... GR based IV, but no GR data in invoice item ---------------*
*----- ... (exception: service PO needs entry sheet number) ----------*
  IF (     i_itemdata-ref_doc        IS INITIAL
        OR i_itemdata-ref_doc_year   IS INITIAL
        OR i_itemdata-ref_doc_it     IS INITIAL )
       AND NOT i_ekpo-webre IS INITIAL
       AND NOT i_ekpo-pstyp = c_pstyp_9
       AND i_itemdata-cond_type  IS INITIAL
       AND i_itemdata-cond_st_no IS INITIAL
       AND i_itemdata-cond_count IS INITIAL.

    e_subrc = 4.
    PERFORM bapireturn_fill USING  'M8'
                                   'E'
                                   '376'
                                   i_itemdata-invoice_doc_item
                                   i_itemdata-po_number
                                   i_itemdata-po_item
                                   space
                          CHANGING te_return.
    PERFORM bapireturn_fill USING  'M8'
                                   'E'
                                   '375'
                                'REF_DOC, REF_DOC_YEAR, REF_DOC_IT'
                                   'ITEMDATA'
                                   i_itemdata-invoice_doc_item
                                   space
                          CHANGING te_return.
  ENDIF.

This means that although you´re using GR Based IV but you´re not informing values in:

i_itemdata-ref_doc

i_itemdata-ref_doc_year

i_itemdata-ref_doc_it

1.3.-


  IF i_itemdata-sheet_no IS INITIAL
      AND NOT i_ekpo-webre IS INITIAL
      AND i_ekpo-pstyp = c_pstyp_9.
    e_subrc = 4.
    PERFORM bapireturn_fill USING  'M8'
                                   'E'
                                   '376'
                                   i_itemdata-invoice_doc_item
                                   i_itemdata-po_number
                                   i_itemdata-po_item
                                   space
                          CHANGING te_return.
    PERFORM bapireturn_fill USING  'M8'
                                   'E'
                                   '375'
                                   'SHEET_NO'
                                   'ITEMDATA'
                                   i_itemdata-invoice_doc_item
                                   space
                          CHANGING te_return.
  ENDIF.

This means that you´re not informing field sheet_no although ekpo-webre and ekpo-pstyp(9) are informed.

Since your case is the second one you must inform GR data in invoice item.

Best regards.

Edited by: Pablo Casamayor on Feb 21, 2011 10:20 AM

Edited by: Pablo Casamayor on Feb 21, 2011 10:21 AM

Read only

0 Likes
6,809

Hi,

2.- The second message is message M8 429

This message is raised here:


*----- GR based IV, but linked GR not existing -----------------------*
  IF NOT i_itemdata-ref_doc IS INITIAL.
    CALL FUNCTION 'MMPUR_EKBE_READ_EBELN_EBELP'
      EXPORTING
        pi_ebeln      = i_itemdata-po_number
        pi_ebelp      = i_itemdata-po_item
      TABLES
        pto_ekbe_po   = tab_ekbe
      EXCEPTIONS
        error_message = 4.
    IF sy-subrc <> 0.
      e_subrc = 4.
      PERFORM bapireturn_fill USING  sy-msgid
                                     sy-msgty
                                     sy-msgno
                                     sy-msgv1
                                     sy-msgv2
                                     sy-msgv3
                                     sy-msgv4
                            CHANGING te_return.
    ENDIF.
    READ TABLE tab_ekbe INTO s_ekbe
                        WITH KEY ebeln = i_itemdata-po_number
                                 ebelp = i_itemdata-po_item
                                 lfbnr = i_itemdata-ref_doc
                                 lfgja = i_itemdata-ref_doc_year
                                 lfpos = i_itemdata-ref_doc_it.
    IF sy-subrc NE 0.
      e_subrc = 4.
      CONCATENATE i_itemdata-ref_doc
                  i_itemdata-ref_doc_year
                  i_itemdata-ref_doc_it
             INTO f_msgv1 SEPARATED BY space.
      PERFORM bapireturn_fill USING  'M8'
                                     'E'
                                     '429'
                                     i_itemdata-po_number
                                     i_itemdata-po_item
                                     f_msgv1
                                     i_itemdata-invoice_doc_item
                            CHANGING te_return.
    ENDIF.
  ENDIF.

This means that you are informing field i_itemdata-ref_doc but there is information missing.

(e.g. i_itemdata-po_number or i_itemdata-po_item or i_itemdata-ref_doc_year or i_itemdata-ref_doc_it)

Best regards.

Read only

0 Likes
6,809

> This means that you´re not informing field sheet_no although ekpo-webre and ekpo-pstyp(9) are informed.

> Since your case is the second one you must inform GR data in invoice item.

This is the point, i have not informed GR data in invoice as there is no GR data yet. Which to be fair is fine for this BAPI to work like this if the standard SAP transaction also worked like this but it doesnt. When Parking this same one via MIR7 it parks fine and i dont get any meesage saying i need to populate GR data!

Mart

Read only

0 Likes
6,809

Hi,

try to park a document with MIR7 and put a break-point in:

include LMRMPU04


*------ incoming invoice ---------------------------------------------*
  CALL FUNCTION 'MRM_INVOICE_DOCUMENT_POST' IN UPDATE TASK
    EXPORTING
      i_rbkp         = s_rbkp
      i_rbkp_blocked = s_rbkp_blocked
      i_rbkpb        = s_rbkpb
....

it seems the document is created here before the COMMIT WORK (include LMR1MF0D routine DOCUMENT_PARK).

Best regards.

Edited by: Pablo Casamayor on Feb 21, 2011 10:57 AM

Read only

0 Likes
6,809

Sorry its probably my question but im not really after how to replicate functionality of MIR7 as i can do this if needs be. But as SAP would not recommend doing this it just seems to be a glaring error in standard SAP which has been around for years, was really hoping someone would have a reason for this or another BAPI where SAP has fixed this issue.

Thanks for your responces so far though they are helping me rationalise the problem to get to the ideal solution!

Regards

Mart

Read only

0 Likes
6,809

Hi,

one relatively easy solution is using this in your development:


  PERFORM mrm_invoice_create_call(saplmrm_bapi)    USING     s_rbkpv
                                               tab_frseg[]
                                               tab_co[]
                                               tab_ma[]
                                               c_rbstat_parked
                                               space
                                     CHANGING  invoicedocnumber
                                               fiscalyear
                                               return[]
                                               f_subrc.

Best regards.

Read only

0 Likes
6,809

This is what is called if i debug passed the GR based checks within the bapi. Unfortunately it wont work as it calls MRM_INVOICE_CREATE from within here which throws up the same error complaining about GR data.

Regards

Read only

0 Likes
6,809

Hi,

here i do not agree with you.

I´m not talking about using BAPI_INCOMINGINVOICE_PARK, i´m talking about using the routine i proposed above.

If you just fill the parameters and make the call to the routine you´re not passing through

PERFORM importing_data_check (of fm BAPI_INCOMINGINVOICE_CREATE)

and

PERFORM itemdata_check (of include LMRM_BAPIF08)

thus avoinding the check you´re fererring to.

Best regards.

Edited by: Pablo Casamayor on Feb 21, 2011 12:01 PM

Read only

0 Likes
6,809

sorry you miss-understood me, if you call 'mrm_invoice_create_call' it eventually calls MRM_INVOICE_CREATE which seems to perform a similer check and stops the processing if no GR data is found.

Read only

0 Likes
6,809

Hi,

MRM_INVOICE_CREATE which seems to perform a similer check

Could you say where exactly is the "similar check"?

Best regards.

Read only

0 Likes
6,809

It seems to fail within the call to FUNCTION 'MRM_INVOICE_CHECK', raises error 607 with reference to field FRSEG-LFBNR being empty, which i believe is the same as REF_DOC.

Read only

0 Likes
6,809

Hi,

maybe you are referring to this:

include LMRMHF07

FORM mrm_frseg_check


  IF i_frseg-webre = 'X' AND ( i_frseg-lfbnr IS INITIAL
                            OR i_frseg-lfgja IS INITIAL )
                         AND i_frseg-xekbz IS INITIAL.
    f_subrc = 4.
    f_fieldname = 'FRSEG-LFBNR'.
  ENDIF.

what i propose is that you make a call thus:


PERFORM mrm_invoice_create_call(saplmrm_bapi)    USING     s_rbkpv
                                               tab_frseg[]
                                               tab_co[]
                                               tab_ma[]
                                               c_rbstat_parked
                                               space
                                     CHANGING  invoicedocnumber
                                               fiscalyear
                                               return[]
                                               f_subrc.

where tab_frseg-webre = space

Best regards.

Edited by: Pablo Casamayor on Feb 21, 2011 2:42 PM

Read only

0 Likes
6,809

If i pass the webre value as initial, it does get past that error but i then get the following error message '708 Item 00010 for purchasing document not selectable' and still doesnt park the document:-(

Read only

0 Likes
6,809

Hi,

the message in question is ME 708 "Item & for purchasing document & not selectable"

This message is raised in three fm´s:

1.- fm ME_READ_ITEM_GOODS_RECEIPT

2.- fm ME_READ_ITEM_INVOICE

3.- ME_READ_ITEM_TRANSFER

The code is:


.....
  CHECK zaehlsel EQ 0.
  PERFORM entsperren_ekpo USING ekko-ebeln ebelp.
  IF zaehlall EQ 1.
    MESSAGE e708 WITH ebelp ebeln
                 RAISING not_valid_one.
    EXIT.
  ELSE.
    MESSAGE e709 WITH ebeln
                 RAISING not_valid_any.
    EXIT.
  ENDIF.

where field zaehlall is the item counter.

Put a break-point in these fm´s and check what is going on.

Best regards.

Read only

0 Likes
6,809

Hi,

i guess it must be happening something like this:

Somewhere in the code the data of the po is read e.g.


*----- read PO item --------------------------------------------------*
    CALL FUNCTION 'ME_EKPO_SINGLE_READ'
      EXPORTING
        pi_ebeln         = s_itemdata-po_number
        pi_ebelp         = s_itemdata-po_item
      IMPORTING
        po_ekpo          = s_ekpo
      EXCEPTIONS
        no_records_found = 1.

and then:


*----- set flag 'GR-based invoice verification' ----------------------*
    s_frseg-webre = s_ekpo-webre.
 

If you have s_ekpo-webre = 'X', that is if you have the flag set on your PO,

this means that you are using IR based on GR

and if you don´t have a GR for that line item then you get an error.

The only solution i see here is to untick the GR indicator in the PO item.

Best regards.

Edited by: Pablo Casamayor on Feb 22, 2011 10:17 AM

Read only

0 Likes
6,809

Hi Mart,

Were you able to solve the above issue ? I have similar one. If yes then pls share.

I was trying for BDC recording to just put the header data in MIR7 as in this case we will not be able to put the line item data. I am facing issuing for tab recording for 'Payment'. Though in the recording the field baseline date(ZFBDT) comes but it does not go to PAYMENT tab and goves error as 'INFVO_ZFBDT' do not exit...Any suggestion is most appreciated.

Read only

0 Likes
6,809

I think I ended up adding an enhancement point to the start of BAPI_INCOMINGINVOICE_CREATE.

Read only

0 Likes
6,809

Hi Mart.

Thanks for reply.

Also can you please tell what was the enhancement you did in  BAPI_INCOMINGINVOICE_CREATE that is, ..purpose of it...were you trying to make the value of WEBRE as space being told above. but you did not use the BAPI_INCOMINGINVOICE_PARK and use CREATE one.

It will be great if you can just provide more information..about the enhancement

Read only

vladimir_andrade
Explorer
0 Likes
6,809

Hola.

Si se trata de una recepción de servicio en el campo i_itemdata-ref_doc se debe colocar el numero de hoja de servicio, es decir la hoja de entrada.

Saludos.