Disenchantment: GPT for generating ABAP code documentation

I just asked a publicly GPT trained model at my company, to generate the documentation of an old and huge ABAP program, to see if ChatGPT can save me some time to understand what the program does.

The prompt is limited to one or two thousand characters, so I can only ask for one portion of a subroutine at a time. The generated text is just good for explaining the meaning of each individual ABAP statement. It cannot save time.

Below are two questions and answers for your information.

Did you have a better experience with GenAI for generating a good ABAP documentation?

Which engine do you use? (public, SAP Joule, privately trained model, etc.)

Thank you.

Sandra

First prompt:

Describe the detailed steps of the subroutine SAVE_COMMENT. Here is its code: FORM save_comment USING p_vl_max_fake p_ok_boolean. CLEAR sg_zfake_user. MOVE sy-datum TO sg_zfake_user-date_2. IF gw_mode = ‘CREER’. MOVE sy-datum TO sg_zfake_user-date_1. MOVE ‘E’ TO sg_zfake_user-statut. ELSE. DELETE FROM zfake_user WHERE nfake = gi_nfake AND typefake = ‘2’. IF sy-subrc <> 0. ENDIF. MOVE g_date_1 TO sg_zfake_user-date_1. MOVE g_statut TO sg_zfake_user-statut. ENDIF. MOVE gi_nfake TO sg_zfake_user-nfake. MOVE ‘2’ TO sg_zfake_user-typefake. MOVE 0 TO sg_zfake_user-notypefake. PERFORM affichage_commentaire USING ‘GET’ tg_fake_commentaire_user_m tg_fake_commentaire_admin_m. LOOP AT tg_fake_commentaire_user_m INTO sg_fake_commentaire. CONCATENATE sg_zfake_user-rubrique1 sg_fake_commentaire INTO sg_zfake_user-rubrique1 SEPARATED BY space. ENDLOOP. CONDENSE sg_zfake_user-rubrique1. MOVE sg_zfake_user-rubrique1 TO g_rubrique1. LOOP AT tg_fake_commentaire_admin_m INTO sg_fake_commentaire. CONCATENATE sg_zfake_user-rubrique2 sg_fake_commentaire INTO sg_zfake_user-rubrique2 SEPARATED BY space. ENDLOOP. CONDENSE sg_zfake_user-rubrique2. MOVE sg_zfake_user-rubrique2 TO g_rubrique2. MOVE p_encopiede TO sg_zfake_user-rubrique3. IF p_encopiede IS NOT INITIAL. CLEAR : b_mdp_ecc, b_sup_ecc , b_sup_decisionnel, sg_zfake_user-rubrique4, sg_zfake_user-rubrique6, sg_zfake_user-rubrique7. ELSE. IF b_mdp_ecc = ‘X’. MOVE ‘X’ TO sg_zfake_user-rubrique4. ENDIF. IF b_mdp_infocentre = ‘X’. MOVE ‘X’ TO sg_zfake_user-rubrique5. ENDIF. IF b_sup_ecc = ‘X’. MOVE ‘X’ TO sg_zfake_user-rubrique6. ENDIF. IF b_sup_decisionnel = ‘X’. MOVE ‘X’ TO sg_zfake_user-rubrique7. ENDIF. ENDIF. INSERT zfake_user FROM sg_zfake_user. IF sy-subrc <> 0. UPDATE zfake_user FROM sg_zfake_user. ENDIF. IF sy-subrc <> 0. MESSAGE ‘Cannot save the comments’ TYPE ‘S’ p_ok_boolean = ‘X’. EXIT. ENDIF. ENDFORM.

The answer:

There’s a problem processing your request. Please try again later or let me know if I can help.

I shortened the prompt:

Describe the detailed steps of the subroutine SAVE_COMMENT. Here is its code: FORM save_comment USING p_vl_max_fake p_ok_boolean. CLEAR sg_zfake_user. MOVE sy-datum TO sg_zfake_user-date_2. IF gw_mode = ‘CREER’. MOVE sy-datum TO sg_zfake_user-date_1. MOVE ‘E’ TO sg_zfake_user-statut. ELSE. DELETE FROM zfake_user WHERE nfake = gi_nfake AND typefake = ‘2’. IF sy-subrc <> 0. ENDIF. MOVE g_date_1 TO sg_zfake_user-date_1. MOVE g_statut TO sg_zfake_user-statut. ENDIF. MOVE gi_nfake TO sg_zfake_user-nfake. MOVE ‘2’ TO sg_zfake_user-typefake. MOVE 0 TO sg_zfake_user-notypefake. PERFORM affichage_commentaire USING ‘GET’ tg_fake_commentaire_user_m tg_fake_commentaire_admin_m. LOOP AT tg_fake_commentaire_user_m INTO sg_fake_commentaire. CONCATENATE sg_zfake_user-rubrique1 sg_fake_commentaire INTO sg_zfake_user-rubrique1 SEPARATED BY space. ENDLOOP.

The answer:

Using publicly trained GPT model…

Sure, let’s break down the subroutine `SAVE_COMMENT` step by step:

Subroutine Definition
FORM save_comment USING p_vl_max_fake p_ok_boolean.
The subroutine SAVE_COMMENT is defined with two parameters: p_vl_max_fake and p_ok_boolean.

Step 1: Clear the Work Area
CLEAR sg_zfake_user.
The work area sg_zfake_user is cleared to ensure it starts with no data.

Step 2: Set the Current Date
MOVE sy-datum TO sg_zfake_user-date_2.
The current system date (sy-datum) is moved to the field date_2 of the work area sg_zfake_user.

Step 3: Check the Mode
IF gw_mode = ‘CREER’.
The subroutine checks if the mode (gw_mode) is ‘CREER’ (which likely means ‘create’).

Step 3.1: If Mode is ‘CREER’
MOVE sy-datum TO sg_zfake_user-date_1.
MOVE ‘E’ TO sg_zfake_user-statut.
The current system date (sy-datum) is moved to the field date_1 of the work area sg_zfake_user.
The status field statut of the work area sg_zfake_user is set to ‘E’.

Step 3.2: If Mode is Not ‘CREER’
ELSE.
DELETE FROM zfake_user WHERE nfake = gi_nfake AND typefake = ‘2’.
IF sy-subrc <> 0.
ENDIF.
MOVE g_date_1 TO sg_zfake_user-date_1.
MOVE g_statut TO sg_zfake_user-statut.
The subroutine deletes entries from the database table zfake_user where nfake equals gi_nfake and typefake equals ‘2’.
If the deletion is not successful (sy-subrc is not zero), it does nothing (empty ENDIF).
The value of g_date_1 is moved to the field date_1 of the work area sg_zfake_user.
The value of g_statut is moved to the field statut of the work area sg_zfake_user.

Step 4: Set Additional Fields
MOVE gi_nfake TO sg_zfake_user-nfake.
MOVE ‘2’ TO sg_zfake_user-typefake.
MOVE 0 TO sg_zfake_user-notypefake.
The value of gi_nfake is moved to the field nfake of the work area sg_zfake_user.
The value ‘2’ is moved to the field typefake of the work area sg_zfake_user.
The value 0 is moved to the field notypefake of the work area sg_zfake_user.

Step 5: Perform Another Subroutine
PERFORM affichage_commentaire USING ‘GET’ tg_fake_commentaire_user_m tg_fake_commentaire_admin_m.
The subroutine affichage_commentaire is called with the parameters ‘GET’, tg_fake_commentaire_user_m, and tg_fake_commentaire_admin_m.

Step 6: Loop Through Internal Table
LOOP AT tg_fake_commentaire_user_m INTO sg_fake_commentaire.
CONCATENATE sg_zfake_user-rubrique1 sg_fake_commentaire INTO sg_zfake_user-rubrique1 SEPARATED BY space.
ENDLOOP.
The subroutine loops through the internal table tg_fake_commentaire_user_m and reads each entry into the work area sg_fake_commentaire.
For each entry, it concatenates the value of sg_fake_commentaire to the field rubrique1 of the work area sg_zfake_user, separated by a space.

End of Subroutine
ENDFORM.
The subroutine ends.

Summary
The SAVE_COMMENT subroutine performs the following actions:

Clears the work area sg_zfake_user.Sets the current date in date_2.Depending on the mode (gw_mode), it either sets the creation date and status or deletes existing entries and sets the date and status from global variables.Sets additional fields in the work area.Calls another subroutine affichage_commentaire.Loops through an internal table and concatenates its entries to a field in the work area.

 

 

​ I just asked a publicly GPT trained model at my company, to generate the documentation of an old and huge ABAP program, to see if ChatGPT can save me some time to understand what the program does.The prompt is limited to one or two thousand characters, so I can only ask for one portion of a subroutine at a time. The generated text is just good for explaining the meaning of each individual ABAP statement. It cannot save time.Below are two questions and answers for your information.Did you have a better experience with GenAI for generating a good ABAP documentation?Which engine do you use? (public, SAP Joule, privately trained model, etc.)Thank you.SandraFirst prompt:Describe the detailed steps of the subroutine SAVE_COMMENT. Here is its code: FORM save_comment USING p_vl_max_fake p_ok_boolean. CLEAR sg_zfake_user. MOVE sy-datum TO sg_zfake_user-date_2. IF gw_mode = ‘CREER’. MOVE sy-datum TO sg_zfake_user-date_1. MOVE ‘E’ TO sg_zfake_user-statut. ELSE. DELETE FROM zfake_user WHERE nfake = gi_nfake AND typefake = ‘2’. IF sy-subrc <> 0. ENDIF. MOVE g_date_1 TO sg_zfake_user-date_1. MOVE g_statut TO sg_zfake_user-statut. ENDIF. MOVE gi_nfake TO sg_zfake_user-nfake. MOVE ‘2’ TO sg_zfake_user-typefake. MOVE 0 TO sg_zfake_user-notypefake. PERFORM affichage_commentaire USING ‘GET’ tg_fake_commentaire_user_m tg_fake_commentaire_admin_m. LOOP AT tg_fake_commentaire_user_m INTO sg_fake_commentaire. CONCATENATE sg_zfake_user-rubrique1 sg_fake_commentaire INTO sg_zfake_user-rubrique1 SEPARATED BY space. ENDLOOP. CONDENSE sg_zfake_user-rubrique1. MOVE sg_zfake_user-rubrique1 TO g_rubrique1. LOOP AT tg_fake_commentaire_admin_m INTO sg_fake_commentaire. CONCATENATE sg_zfake_user-rubrique2 sg_fake_commentaire INTO sg_zfake_user-rubrique2 SEPARATED BY space. ENDLOOP. CONDENSE sg_zfake_user-rubrique2. MOVE sg_zfake_user-rubrique2 TO g_rubrique2. MOVE p_encopiede TO sg_zfake_user-rubrique3. IF p_encopiede IS NOT INITIAL. CLEAR : b_mdp_ecc, b_sup_ecc , b_sup_decisionnel, sg_zfake_user-rubrique4, sg_zfake_user-rubrique6, sg_zfake_user-rubrique7. ELSE. IF b_mdp_ecc = ‘X’. MOVE ‘X’ TO sg_zfake_user-rubrique4. ENDIF. IF b_mdp_infocentre = ‘X’. MOVE ‘X’ TO sg_zfake_user-rubrique5. ENDIF. IF b_sup_ecc = ‘X’. MOVE ‘X’ TO sg_zfake_user-rubrique6. ENDIF. IF b_sup_decisionnel = ‘X’. MOVE ‘X’ TO sg_zfake_user-rubrique7. ENDIF. ENDIF. INSERT zfake_user FROM sg_zfake_user. IF sy-subrc <> 0. UPDATE zfake_user FROM sg_zfake_user. ENDIF. IF sy-subrc <> 0. MESSAGE ‘Cannot save the comments’ TYPE ‘S’ p_ok_boolean = ‘X’. EXIT. ENDIF. ENDFORM.The answer:There’s a problem processing your request. Please try again later or let me know if I can help.I shortened the prompt:Describe the detailed steps of the subroutine SAVE_COMMENT. Here is its code: FORM save_comment USING p_vl_max_fake p_ok_boolean. CLEAR sg_zfake_user. MOVE sy-datum TO sg_zfake_user-date_2. IF gw_mode = ‘CREER’. MOVE sy-datum TO sg_zfake_user-date_1. MOVE ‘E’ TO sg_zfake_user-statut. ELSE. DELETE FROM zfake_user WHERE nfake = gi_nfake AND typefake = ‘2’. IF sy-subrc <> 0. ENDIF. MOVE g_date_1 TO sg_zfake_user-date_1. MOVE g_statut TO sg_zfake_user-statut. ENDIF. MOVE gi_nfake TO sg_zfake_user-nfake. MOVE ‘2’ TO sg_zfake_user-typefake. MOVE 0 TO sg_zfake_user-notypefake. PERFORM affichage_commentaire USING ‘GET’ tg_fake_commentaire_user_m tg_fake_commentaire_admin_m. LOOP AT tg_fake_commentaire_user_m INTO sg_fake_commentaire. CONCATENATE sg_zfake_user-rubrique1 sg_fake_commentaire INTO sg_zfake_user-rubrique1 SEPARATED BY space. ENDLOOP.The answer:Using publicly trained GPT model…Sure, let’s break down the subroutine `SAVE_COMMENT` step by step:Subroutine DefinitionFORM save_comment USING p_vl_max_fake p_ok_boolean.The subroutine SAVE_COMMENT is defined with two parameters: p_vl_max_fake and p_ok_boolean.Step 1: Clear the Work AreaCLEAR sg_zfake_user.The work area sg_zfake_user is cleared to ensure it starts with no data.Step 2: Set the Current DateMOVE sy-datum TO sg_zfake_user-date_2.The current system date (sy-datum) is moved to the field date_2 of the work area sg_zfake_user.Step 3: Check the ModeIF gw_mode = ‘CREER’.The subroutine checks if the mode (gw_mode) is ‘CREER’ (which likely means ‘create’).Step 3.1: If Mode is ‘CREER’MOVE sy-datum TO sg_zfake_user-date_1.MOVE ‘E’ TO sg_zfake_user-statut.The current system date (sy-datum) is moved to the field date_1 of the work area sg_zfake_user.The status field statut of the work area sg_zfake_user is set to ‘E’.Step 3.2: If Mode is Not ‘CREER’ELSE.DELETE FROM zfake_user WHERE nfake = gi_nfake AND typefake = ‘2’.IF sy-subrc <> 0.ENDIF.MOVE g_date_1 TO sg_zfake_user-date_1.MOVE g_statut TO sg_zfake_user-statut.The subroutine deletes entries from the database table zfake_user where nfake equals gi_nfake and typefake equals ‘2’.If the deletion is not successful (sy-subrc is not zero), it does nothing (empty ENDIF).The value of g_date_1 is moved to the field date_1 of the work area sg_zfake_user.The value of g_statut is moved to the field statut of the work area sg_zfake_user.Step 4: Set Additional FieldsMOVE gi_nfake TO sg_zfake_user-nfake.MOVE ‘2’ TO sg_zfake_user-typefake.MOVE 0 TO sg_zfake_user-notypefake.The value of gi_nfake is moved to the field nfake of the work area sg_zfake_user.The value ‘2’ is moved to the field typefake of the work area sg_zfake_user.The value 0 is moved to the field notypefake of the work area sg_zfake_user.Step 5: Perform Another SubroutinePERFORM affichage_commentaire USING ‘GET’ tg_fake_commentaire_user_m tg_fake_commentaire_admin_m.The subroutine affichage_commentaire is called with the parameters ‘GET’, tg_fake_commentaire_user_m, and tg_fake_commentaire_admin_m.Step 6: Loop Through Internal TableLOOP AT tg_fake_commentaire_user_m INTO sg_fake_commentaire.CONCATENATE sg_zfake_user-rubrique1 sg_fake_commentaire INTO sg_zfake_user-rubrique1 SEPARATED BY space.ENDLOOP.The subroutine loops through the internal table tg_fake_commentaire_user_m and reads each entry into the work area sg_fake_commentaire.For each entry, it concatenates the value of sg_fake_commentaire to the field rubrique1 of the work area sg_zfake_user, separated by a space.End of SubroutineENDFORM.The subroutine ends.SummaryThe SAVE_COMMENT subroutine performs the following actions:Clears the work area sg_zfake_user.Sets the current date in date_2.Depending on the mode (gw_mode), it either sets the creation date and status or deletes existing entries and sets the date and status from global variables.Sets additional fields in the work area.Calls another subroutine affichage_commentaire.Loops through an internal table and concatenates its entries to a field in the work area.    Read More Technology Blogs by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author