cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP OData WebService DataModel for CREATE-Operation - Am i doing this the intended way?

Mirco91
Newcomer
0 Kudos
113

I am currently working on a project to upgrade existing SAP Function Models from external RFC to OData Rest-Services.

Certain things are set:

  • it has to be OData and REST
  • the interface has to be as close to the original as possible

The given Function Model has the followong architecture:

  • IMPORT
    • iv_testrun type BOOL
  • EXPORT
    • es_return like BAPIRET2
  • TABLES
    • IT_TIMETICKETS
    • ET_DETAIL_RETURN

The function model works relativly easy:

  • IMPORT is self-explanatory
  • EXPORT is given if something goes wrong which kills the processing
  • TABLES
    • the timetickets which shall be created to an existing order
    • the detailed return gives a message for each given ticket if the creation was succesfull or not and some details what went wrong

Knowing my way around the SEGW and the DPC, DPC_EXT, MPC, MPC_EXT -Classes i designed a webservice with a deep_entity setup.

  1. i created a KEY-Entity with a literal Key called ConfCreate to later connect the importing Values to.
  2. i created the VALUE-Entity which has basically all the inputs of IT_TIMETICKETS. This i connecte via an association with the KEY-Entity settings set on 1 to M.
  3. To get the detailed results i went in my opinion a bit sketchi... i created a third entity called RETURN. this on i also connected to the KEY-Entity with an association.

so overall the segw looks something like this:

Mirco91_0-1747199797665.png

and the associations look like this:

Mirco91_1-1747200102200.png

lastly i redefined the CREATE_DEEP_ENTITY Method of the DPC_EXT and voilà, it works...
...but its kind of ugly and it feels "done in the wrong way"

so this is the request:

{
  "Testrun": "",
  "Values": {
    "results": [
      {
        "ConfNo": "1",
        "Orderid": "",
        "Operation": "",
        "SubOper": "",
        "CapaCategory": ""
      },
      {
        "ConfNo": "2",
        "Orderid": "",
        "Operation": "",
        "SubOper": "",
        "CapaCategory": ""
      }
    ]
  },
  "Returns": []
}

ConfCreate is, as already explained, the "link" to the Value-Entries.
Testrun defines if it´s a testrun or not. Since both have to be adressable i defined them as KEYS.
And in Values, we have the timeticket-values which we can give noumerous at once into the service.

... And then there is results ... 
this is left blank because it is needed to be automatically in the tech_clauses, which is a string_table defining what goes in AND comes out.

If there should be a general error we get a 40X or 50X http status and if there is a business wrongdoing we get the results filled as intended

this is an example response:

[...]
    "Returns": {
      "results": [
        {
          "__metadata": {
            "id": "https://.../sap/opu/odata/sap/Z...CONF_CREATE_SRV_01/ReturnSet(ConfCreate='',Testrun='')",
            "uri": "https://.../sap/opu/odata/sap/Z...CONF_CREATE_SRV_01/ReturnSet(ConfCreate='',Testrun='')",
            "type": "Z...CONF_CREATE_SRV_01.Return"
          },
          "ConfCreate": "",
          "Testrun": "",
          "Type": "E",
          "MessageId": "RU",
          "MessageNumber": "020",
          "Message": "Rückmeldenr. 1 nicht vorhanden (Bitte Eingabe prüfen)",
          "LogNumber": "",
          "LogMsgNo": "000000",
          "MessageV1": "1",
          "MessageV2": "",
          "MessageV3": "",
          "MessageV4": "",
          "Parameter": "",
          "Row": 1,
          "Field": "",
          "System": "A05_010",
          "FlgLocked": false,
          "ConfNo": "0000000000",
          "ConfCnt": "00000000"
        },
        {
          "__metadata": {
            "id": "https://.../sap/opu/odata/sap/Z...CONF_CREATE_SRV_01/ReturnSet(ConfCreate='',Testrun='')",
            "uri": "https://.../sap/opu/odata/sap/Z...CONF_CREATE_SRV_01/ReturnSet(ConfCreate='',Testrun='')",
            "type": "Z...CONF_CREATE_SRV_01.Return"
          },
          "ConfCreate": "",
          "Testrun": "",
          "Type": "E",
          "MessageId": "RU",
          "MessageNumber": "020",
          "Message": "Rückmeldenr. 2 nicht vorhanden (Bitte Eingabe prüfen)",
          "LogNumber": "",
          "LogMsgNo": "000000",
          "MessageV1": "2",
          "MessageV2": "",
          "MessageV3": "",
          "MessageV4": "",
          "Parameter": "",
          "Row": 2,
          "Field": "",
          "System": "A05_010",
          "FlgLocked": false,
          "ConfNo": "0000000000",
          "ConfCnt": "00000000"
        }
      ]
    }
  }
}

so now we come to my question:

Is this really the intended way of solving sth like this?

Is there a more fitting configuration and setup hidden inside the SEGW i do not know yet?

So please, if someone is experienced with mass-creates and explicit returns for each individual create please let me know.

 

Kind Regards
Mirco

Accepted Solutions (0)

Answers (0)