EDUCAÇÃO E TECNOLOGIA

Hassle-free way to frequently change long string data in database without file upload

Problem Statement:

You do not have a user interface or an application ready to save the data in ABAP dictionary object, and you need to upload the data into a database table.

The above does not seem to be a problem because you can generate Table Maintenance Generator.

Wait wait wait! The problem is yet to come.

The table has a string field and TMG creation gives this error “Data type STRING is not supported in field”.

Seems a problem now, but a smaller one? 

Yes?

Yes, it seems small until we do not know that our requirement is to store a string of length greater than 255 characters.

You might be wondering that it’s so simple to create an ABAP report that calls a standard function module to upload the data.

Yes? 

Then hold your horses, the real problem is here.

Problem Number 1: Most of the Function Modules have the restriction of uploading up to 255 characters only.

Oh No!

After a lot of huff and puff you were able to find an appropriate function module GUI_UPLOAD.

GUI_UPLOAD%20FM

GUI_UPLOAD FM

Feeling better?

Sorry but we have another problem to disappoint you.

Problem Number 2: Imagine you have data in a format like JSON which you need to change frequently for testing purpose and upload this data in string format in the database table. So, you will

  • create a report where you
    • need to read the JSON file
    • convert the data as per your requirement.
    • integrate GUI_UPLOAD function
  • make required changes to the JSON file
  • execute the ABAP report
  • upload the file

Next time, when you need a change, you will repeat the complete process.

Imagine, when this change is required multiple times in a day by multiple users. How much time it would consume?

You can save that time and make a coffee for yourself.

Can you think of a solution where just making the change and a click serves the purpose?

If yes, then post the solutions coming in your mind in comment section.

Solution:

Create an API to save data in the database table and call that API via any REST client like postman.

Woohoo!

This would

  • solve the limitation of 255 character &
  • It would not require uploading the file every time a change is required

Step by step guide to set this up in Postman API platform:

Step1: Create a post request

Create a new request and change its type to POST

Create%20a%20POST%20type%20request

Create a POST type request

Step 2: Enter the URL of the API to save data

Enter%20the%20URL

Enter the URL

Step 3: Go to “Params” and maintain the required parameters like sap-client

Maintain%20Params

Maintain Params

Step 4: Go to “Authorisation” tab and maintain the credentials

Maintain%20Credentials

Maintain Credentials

Step 5: Go to “Headers” tab and maintain information given

Headers%20Info

Headers Info

Step 6: Go to body and maintain the data to be saved in table

Body Info

Here, the template needs to have the string that has length more than 255.

Now, let’s see where we can maintain that data.

Step 7: Go to pre-request Script and maintain the data

Pre-request%20Script

Pre-request Script

The “query” variable can hold any length of JSON object and then following statement will

convert the object to string and this variable gets assigned to the table field as per the config done in step 6.

pm.collectionVariables.set('query', JSON.stringify(JSON.stringify(query)));

The above is just a one time job and whenever you need a change just make the change in JSON formatted data in Pre-request Script and press send.