7

ChatGPT usecase for ABAP code and SAP help

 1 year ago
source link: https://blogs.sap.com/2023/01/08/chatgpt-usecase-for-abap-code-and-sap-help/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
January 8, 2023 2 minute read

ChatGPT usecase for ABAP code and SAP help

7 2 151

ChatGPT would soon disrupt ABAP coding too. This AI tool is known for creating codes for java, C, and C# very accurately in a few seconds. The blog post is a test case for ChatGPT accuracy for the SAP ABAP code. Although output is not 100% accurate, since it is an AI-based model, it will learn soon and produce 100% accurate Abap codes.

My simple test of code generation through ChatGPT was 100% accurate.

Abap.jpg

Second use case as a functional analyst:

Abap-2.jpg
Abap-3.jpg

3-rd use case: Want to give Functional specification for a business case. You can see FS-pseudo logic generated and the code itself.

-My input to ChatGPT: I need custom code in user Exit EXIT_SAPLFKKH_002 of sap. If Material type is not FERT , release production order, else give message – release not allowed

Chat GPT output :

To implement this functionality, you can follow the steps below:

  1. Create a user exit in the SAP system. You can do this by using the transaction code CMOD and following the prompts to create a new enhancement project.
  2. In the user exit function module, you can check the material type of the production order by using the function module MD_ORDER_READ_MAT_TYPE. This function module takes the production order number as an input and returns the material type of the order.
  3. If the material type is not FERT, you can release the production order using the function module CORU_ORDER_RELEASE.
  4. If the material type is FERT, you can display a message to the user indicating that the release is not allowed using the function module MESSAGE_TYPE_X.

Here is some sample code that demonstrates how you can implement this functionality in the user exit:

Code-

*Importing required function modules
IMPORTING
f_order_number TYPE coru_order_number
f_material_type TYPE mard-mtart
f_order_released TYPE coru_order_released
f_message_type TYPE sy-msgty
f_message_text TYPE sy-msgv1
EXPORTING
e_order_released TYPE coru_order_released
e_message_type TYPE sy-msgty
e_message_text TYPE sy-msgv1
TABLES
t_order_components STRUCTURE coru_t_order_components.

*Read material type of the production order
CALL FUNCTION ‘MD_ORDER_READ_MAT_TYPE’
EXPORTING
i_order_number = f_order_number
IMPORTING
e_material_type = f_material_type
EXCEPTIONS
order_not_found = 1
OTHERS = 2.

*Check if material type is not FERT
IF f_material_type NE ‘FERT’.

*Release production order
CALL FUNCTION ‘CORU_ORDER_RELEASE’
EXPORTING
i_order_number = f_order_number
IMPORTING
e_order_released = f_order_released
EXCEPTIONS
OTHERS = 1.

*Set message type and text for release success
e_message_type = ‘S’.
e_message_text = ‘Production order released successfully’.

ELSE.

*Set message type and text for release not allowed
e_message_type = ‘E’.
e_message_text = ‘Release not allowed for material type FERT’.

ENDIF.

Hmmm..Be ready for massive disruptions in technology.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK