Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROFITCENTER_DOCUMENT_POST throws errors 440, 570 and 700 #167

Closed
matthiasf1 opened this issue Apr 4, 2020 · 5 comments
Closed

PROFITCENTER_DOCUMENT_POST throws errors 440, 570 and 700 #167

matthiasf1 opened this issue Apr 4, 2020 · 5 comments

Comments

@matthiasf1
Copy link

I try to upload profitcenter bookings in SAP with PROFITCENTER_DOCUMENT_POST but I'm getting errors 440, 570 and 700:
{'RETURN': {'TYPE': 'E', 'ID': 'KM', 'NUMBER': '440', 'MESSAGE': '', 'LOG_NO': '', 'LOG_MSG_NO': '000000', 'MESSAGE_V1': '', 'MESSAGE_V2': '', 'MESSAGE_V3': '', 'MESSAGE_V4': '', 'PARAMETER': '', 'ROW': 0, 'FIELD': '', 'SYSTEM': ''}, 'LINEDATA': [{'PROFIT_CTR': '123456', 'GL_ACCOUNT': '123456', 'IN_TC': Decimal('123456.12'), 'PART_PRCTR': '123456', 'PLANT': '', 'FUNC_AREA': '', 'TRADE_ID': '', 'S_COMP_CODE': '', 'PARTNER_FUNC_AREA': '', 'CS_TRANS_T': '', 'OBJECTCLASS': '', 'REP_MATERIAL': '', 'DEPR_AREA': '00'}], 'LMESSAGE': [{'TYPE': 'E', 'ID': 'KM', 'NUMBER': '700', 'MESSAGE': '', 'LOG_NO': '', 'LOG_MSG_NO': '000000', 'MESSAGE_V1': '1000', 'MESSAGE_V2': '123456', 'MESSAGE_V3': '30122019', 'MESSAGE_V4': '', 'PARAMETER': '', 'ROW': 0, 'FIELD': '', 'SYSTEM': ''}, {'TYPE': 'E', 'ID': 'KM', 'NUMBER': '700', 'MESSAGE': '', 'LOG_NO': '', 'LOG_MSG_NO': '000000', 'MESSAGE_V1': '1000', 'MESSAGE_V2': '123456', 'MESSAGE_V3': '30122019', 'MESSAGE_V4': '', 'PARAMETER': '', 'ROW': 0, 'FIELD': '', 'SYSTEM': ''}, {'TYPE': 'E', 'ID': 'KM', 'NUMBER': '570', 'MESSAGE': '', 'LOG_NO': '', 'LOG_MSG_NO': '000000', 'MESSAGE_V1': '123456', 'MESSAGE_V2': '1000', 'MESSAGE_V3': 'GKR', 'MESSAGE_V4': '', 'PARAMETER': '', 'ROW': 0, 'FIELD': '', 'SYSTEM': ''}]}
Referring to the messages in Profit Center Accounting in sapdatasheet.org:

440 is "Error messages exist"
570 is "No master data found for account &1 in chart of accounts &3"
and 700 is "Profit center &1/&2 does not exist for &3"

With the mentioned parameters I can perform the booking in SAP, so in general it should be possible.

Can somebody give me advise on what I'm missing?

Please see my code below:

from pyrfc import Connection
from configparser import ConfigParser
import datetime

class main():
    def __init__(self):
        config = ConfigParser()
        config.read('sapnwrfc.cfg')
        params_connection = config._sections['connection']
        self.conn = Connection(**params_connection)     

    def qry(self, posting_date, BUKR, Profitcenter, Partnerprofitcenter, Betrag, GL_Account):

        table = self.conn.call("PROFITCENTER_DOCUMENT_POST",
                                    HEADDATA = 
                                    {"KURST" : "M",
                                    "DOCUMENT_TYPE" : "A0",
                                    "PSTNG_DATE" : posting_date,
                                    "COMP_CODE" : BUKR,
                                    "CURRENCY" : "EUR  ",
                                    "SPEC_PERIOD" : ""
                                    },
                                   
                                    LINEDATA = 
                                    [{"PROFIT_CTR" : Profitcenter,
                                    "GL_ACCOUNT" : GL_Account,
                                    "IN_TC" : Betrag,
                                    "PART_PRCTR" : Partnerprofitcenter}
                                    ])
        return table

s = main()

posting_date = datetime.date(2019, 12, 30)
BUKR = "0012"
Profitcenter = "123456"
Partnerprofitcenter = "123456"
Betrag = 123456.12
GL_Account = "123456"

table = s.qry(posting_date, BUKR, Profitcenter, Partnerprofitcenter, Betrag, GL_Account)

print(table)
@bsrdjan
Copy link
Member

bsrdjan commented Apr 6, 2020

When certain parameter work in ABAP transactions and does not work from Python, the cause is usually a Conversion Exit, implemented for that parameter on ABAP side: RFC call results differ from expected

Looking into PROFITCENTER_DOCUMENT_POST parameters data definition on ABAP side, Conversion Exits are implemented in LINEDATA structure:

ALPHA for PROFIT_CTR, PART_PRCTR, GL_ACCOUNT fields
AC152 for IN_TC field

It can be fixed by implementing a PROFITCENTER_DOCUMENT_POST wrapper on ABAP side, triggering inbound/outbound Conversion Exits, so that Python application works with parameters identical as in ABAP. This is recommended solution, or even better, using a standard API if available.

The ABAP Conversion Exit logic can be also replicated on Python side, like adding leading zeroes PROFIT_CTR, PART_PRCTR, GL_ACCOUNT for example. This can fork for quick testing and is not recommended.

@matthiasf1
Copy link
Author

Hi Srdjan, thanks a lot for your reply. I tried the second version for testing with adding leading zeros but although I get a success message and an appertaining document number I can't find the booking neither using the GUI, nor by reading the table "GLPCA" which is contains the already made bookings.

Concerning the preferred first method you mentioned:

  • how can I implement a wrapper for PROFITCENTER_DOCUMENT_POST? Is it possible to implement the wrapper within my Python script / do you have an example where something similar is done or is there somewhere an instruction on how to do so?
  • which standard APIs can I use in this case?

@bsrdjan
Copy link
Member

bsrdjan commented Apr 28, 2020

Sorry that I can't help further here, the question is more for SAP FI consultant.

With new G/L in the ECC and then with the Universal Journal in S/4 Hana, the profit center invoice was integrated into the general ledger. Classic profit center accounting can still be used by in parallel, but not really recommended by SAP and is no longer being developed. Better check with SAP FI experts, who might have more knowledge/info on this.

@bsrdjan bsrdjan closed this as completed May 25, 2020
@bsrdjan
Copy link
Member

bsrdjan commented Aug 11, 2020

Just published the rfmcall utility, helpful for catching ALPHA exits, among other things.

It is for nodejs and the output is (for the time being) in JS but with few search/replace you can get the Python output.

Feedback welcome

@Idan-fishman-old
Copy link

Idan-fishman-old commented Aug 11, 2020

I have done it.
I created an image based on python:3.8.5-slim-buster works with pynwrfc and the size is only 165MB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants