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

how to add a field in ALV of transaction IW47

mark_fryu
Participant
1,911

hi,

i added a custom field in append in RIHAFVR structure.

But when i launch transaction IW47 the field is not displayed in alv.

How can i display the field?

 

thank you

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor
0 Kudos

There are two solutions to add a custom field to IW47 ALV:

  1. EITHER create an append on DDIC structure RIHAFVR, in which you add the field (preferred solution)
  2. OR enhance the global structure/internal table OBJECT_TAB in RIAFRU20 via the Enhancement Framework + enhance the field catalog (global variable G_FIELDCAT_TAB in RIAFRU20) via CMOD IWOC0004 exit_saplirep1_001 (include ZXCSVU09), but this is not recommended by SAP (*)

Of course, you need to fill the new field of the internal table, do that wherever you want via the Enhancement Framework.

After that, empty the ALV field catalog buffer (run the program BALVBUFDEL) because IW47/RIAFRU20 uses the ALV buffer.

NB concerning the internal details of RIAUFR20. It calls the FM REUSE_ALV_FIELDCATALOG_MERGE with the parameter I_INTERNAL_TABNAME="OBJECT_TAB" to determine the initial field catalog, this FM considers all custom fields appended to the included structures (RIHAFVR) but not the fields appended by the Enhancement Framework, hence you need to do an enhancement to update the field catalog for these fields.

(*) NB the documentation of exit_saplirep1_001 says: "You can modify the field attributes in the field catalog IT_FIELDCAT using this customer exit. However, we must point out that the table as a whole should not be modified, that is, you should neither add nor delete rows."

NB: to consider the latest program modifications, you must restart the program (/NIW47 or /NSE38 RIAFRU20).

Answers (1)

Answers (1)

mark_fryu
Participant
0 Kudos

hi @Sandra_Rossi 

ok thank you, is there also a way to add the field without modifying the RIHAFVR structure?

I tried to add the field, but I get the following error:

mark_fryu_0-1727451289152.png

 

Sandra_Rossi
Active Contributor
0 Kudos
This error happens because you use TYPES, but you should use DATA here. It seems that you have tried "DATA ztest TYPE ztest" so I guess that it didn't work, what error message did you get?
mark_fryu
Participant
0 Kudos

hi @Sandra_Rossi 

with DATA ztest TYPE ztest it is ok, but the execution dumps

do I have to do an append in the G_FIELDCAT_TAB table?

I implemented an enhancement by doing an append, is it correct?

mark_fryu_2-1727473804082.png

this is the dump

mark_fryu_0-1727474602838.png

 

in this point:

mark_fryu_1-1727474616740.png

 

 

thank you @Sandra_Rossi 

 

 

Sandra_Rossi
Active Contributor
0 Kudos
Isn't it obvious when you debug? The field you think you have added to the internal table (<LS_DATA> is one line) is in fact not added, hence defining your field in the field catalog makes it dump. Are you sure that the enhancement spot you have implemented to add your field is active in your system? (ES_RIAFRU20)
mark_fryu
Participant
0 Kudos

Hi @Sandra_Rossi 

yes the enhancement is active, in fact if I deactivate it then it no longer goes into dump.

sorry I didn't understand the solution you proposed, do I have to change the method to do the append in the internal table g_fieldcat_tab ?

What is ES_RIAFRU20 ? I implemented enhancement in the report RIAFRU20

Thank you

Sandra_Rossi
Active Contributor
0 Kudos

I'm talking about the Enhancement Spot ES_RIAFRU20 which I think you have enhanced. See your screenshot annotated below. If you enhance something inactive, your enhancement will be inactive too.

Sandra_Rossi_0-1727536379044.png

mark_fryu
Participant
0 Kudos

Hi @Sandra_Rossi 

I checked and it is active. However I saw that in debug I can not put a breakpoint on the enhancement that I created, is it normal? and in debug I only see the enhancement point and not my ZCustom_enanancement

Sandra_Rossi
Active Contributor
0 Kudos
Sometimes breakpoints may be tricky to set for enhancements. Try temporarily with the ABAP statement BREAK-POINT. If you still don't stop, it means that your Enhancement Implementation is not active. Did you activate it?
mark_fryu
Participant
0 Kudos

hi @Sandra_Rossi 

yes it's active:

mark_fryu_0-1727553687623.png

 

Sandra_Rossi
Active Contributor
0 Kudos
Okay but do you now stop at BREAK-POINT? If no, then did you check the Enhancement Spot? You have said "yes the enhancement is active" but it seems you were talking about your own Enhancement Implementation. I suggest that you learn the concept and elements of the Enhancement Framework, because you seem to be confused.
Sandra_Rossi
Active Contributor

Conclusion: I did the same code as you, i.e. extending OBJECT_TAB via the enhancement spot, adding the new field to the field catalog (CMOD IWOC0004 exit_saplirep1_001 ZXCSVU09), emptied the ALV field catalog buffer (BALVBUFDEL) because IW47/RIAFRU20 uses the ALV buffer, I ran the program, filled by debug the new field in OBJECT_TAB, and this value was displayed by the ALV of IW47.

Sorry, I can't do more.

NB: RIAUFR20 calls the FM REUSE_ALV_FIELDCATALOG_MERGE with the parameter I_INTERNAL_TABNAME="OBJECT_TAB" to determine the initial field catalog, this FM considers all custom fields appended to the included structures (RIHAFVR) but not the fields appended by the Enhancement Framework, hence you need to do an enhancement to update the field catalog for these fields.

NB: exit_saplirep1_001 documentation says "You can modify the field attributes in the field catalog IT_FIELDCAT using this customer exit. However, we must point out that the table as a whole should not be modified, that is, you should neither add nor delete rows."

Sandra_Rossi
Active Contributor
NB: to consider the latest program modifications, you must restart the program.
mark_fryu
Participant

hi @Sandra_Rossi 

thank you very much you were very kind 🙂
I'm just asking to be sure I understood, so to add a field I have to modify the RIHAFVR structure, is this correct?

and for this: "NB: to consider the latest program modifications, you must restart the program."

how can I restart the program?

Sandra_Rossi
Active Contributor
0 Kudos
There are two solutions to add a custom field to IW47 ALV, EITHER 1) create an append on DDIC structure RIHAFVR, OR 2) enhance OBJECT_TAB + enhance G_FIELDCAT_TAB. Restart the program: /NIW47 or /NSE38 RIAFRU20.
mark_fryu
Participant
0 Kudos

hi @Sandra_Rossi 

thank you!

Did you also implement the user exit? CMOD IWOC0004 exit_saplirep1_001 ZXCSVU09?

Sandra_Rossi
Active Contributor
0 Kudos
Should I really always cross the Ts and dot the Is for you? Don't you understand by reading the official documentation that the enhancement of G_FIELDCAT_TAB corresponds to "CMOD IWOC0004 exit_saplirep1_001 ZXCSVU09"? Did you try anything? What is your issue?