2020 Nov 25 4:26 PM
HI EXPERT
when i excute program i see this erroe and i dont know whay can you help me ?where is my problem I do not see this message when I use OCCURSE 0 to define the internal table, but I do not want to use OCCURSE 0 THANK YOUTYPE-POOLS :SLIS.
TYPES : BEGIN OF TY_MSEG ,
MANDT LIKE MSEG-MANDT,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
ZEILE LIKE MSEG-ZEILE,
END OF TY_MSEG .
DATA : IT_MSEG TYPE TABLE OF TY_MSEG WITH HEADER LINE,
WA_MSEG TYPE TY_MSEG.
SELECT-OPTIONS : S_MBLNR FOR IT_MSEG-MBLNR ,
S_MJAHR FOR IT_MSEG-MJAHR .
DATA: gv_progname LIKE sy-repid.
gv_progname = sy-repid.
START-OF-SELECTION .
PERFORM GET_DATA .
PERFORM VALIDATE_FIELDCAT .
PERFORM DISPLAY_DATA .
FORM GET_DATA .
SELECT MSEG~MANDT
MSEG~MBLNR
MSEG~MJAHR
MSEG~ZEILE
INTO TABLE IT_MSEG
FROM MSEG
WHERE MBLNR IN S_MBLNR AND MJAHR IN S_MJAHR .
ENDFORM .
FORM VALIDATE_FIELDCAT .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = gv_progname
I_INTERNAL_TABNAME = 'IT_MSEG'
I_INCLNAME = gv_progname
CHANGING
CT_FIELDCAT = IT_FCAT[].
ENDFORM.
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = gv_progname
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_MSEG.
ENDFORM .
2020 Dec 01 7:37 AM
The run time error NO_FIELDCATALOG_AVAILABLE may happen when it's called by REUSE_ALV_FIELDCATALOG_MERGE.
The issue with REUSE_ALV_FIELDCATALOG_MERGE is that it's very old, and if you use I_INTERNAL_TABNAME, and want to use modern syntax (no header line), the only possibility is to declare the structure via a variable (DATA), not a type, and you must pass the name of that structured variable to the parameter I_INTERNAL_TABNAME of REUSE_ALV_FIELDCATALOG_MERGE.
Another solution is to define the structure in the DDIC, and you don't need to use neither REUSE_ALV_FIELDCATALOG_MERGE, nor I_INTERNAL_TABNAME, unless you want to adapt the returned catalog.
Of course, you will avoid a lot of pain if you use CL_SALV_TABLE instead of the obsolete REUSE_* and CL_GUI_ALV_GRID.
Working code (note that LIKE used with a DDIC type is obsolete, you should use a variable - WA_DUMMY_MSEG below):
DATA: WA_DUMMY_MSEG TYPE MSEG.
DATA: BEGIN OF WA_MSEG ,
MANDT LIKE WA_DUMMY_MSEG-MANDT,
MBLNR LIKE WA_DUMMY_MSEG-MBLNR,
MJAHR LIKE WA_DUMMY_MSEG-MJAHR,
ZEILE LIKE WA_DUMMY_MSEG-ZEILE,
END OF WA_MSEG .
DATA : IT_MSEG LIKE TABLE OF WA_MSEG.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA: gv_progname LIKE sy-repid.
SELECT-OPTIONS : S_MBLNR FOR WA_MSEG-MBLNR ,
S_MJAHR FOR WA_MSEG-MJAHR .
START-OF-SELECTION .
gv_progname = sy-repid.
PERFORM GET_DATA .
PERFORM VALIDATE_FIELDCAT .
PERFORM DISPLAY_DATA .
FORM GET_DATA .
SELECT MSEG~MANDT
MSEG~MBLNR
MSEG~MJAHR
MSEG~ZEILE
INTO TABLE IT_MSEG
FROM MSEG
WHERE MBLNR IN S_MBLNR AND MJAHR IN S_MJAHR .
ENDFORM .
FORM VALIDATE_FIELDCAT .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = gv_progname
I_INTERNAL_TABNAME = 'WA_MSEG'
I_INCLNAME = gv_progname
CHANGING
CT_FIELDCAT = IT_FCAT.
ENDFORM.
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = gv_progname
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_MSEG.
ENDFORM .
2020 Nov 25 5:31 PM
I think it has already been mentioned in the recent days but a better way to handle an ALV is with the CL_SALV_TABLE class:
DATA: alv TYPE REF TO cl_salv_table,
message TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table = IT_MSEG[] ).
CATCH cx_salv_msg INTO message.
" error handling
ENDTRY.
alv->display( ).
Easier to read, no need to create a catalog.
Extending the answer after your comment.
Since you're starting out now, it might make sense to skip the old stuff and go straight to the newer one: breaking habits once formed is twice as hard as learning good ones.
Anyhow, REUSE_ALV_FIELDCATALOG_MERGE works by scanning the source code looking for a specific declaration made with OCCURS and LIKE. Nothing happens without them.
2020 Nov 25 6:32 PM
dear c5e08e0478aa4727abc4482f5be390b2
thank you so much
Honestly, I am a begginer and I have to be the same as I was trained in the beginning To do means 'REUSE_ALV_FIELDCATALOG_MERGE'Thank you for telling me your problem in this regard
Your answers have always been great
2020 Nov 25 7:45 PM
DEAR
Yes, you are absolutely right and I agree .
But unfortunately my manager does not allow me and I want to do it this way,
although it is the old method, unfortunately he is very interested in the "REUSE_ALV_FIELDCATALOG_MERGE"
He even asked me not to use OCCURS 0
2020 Nov 26 4:59 AM
Good for display-only purposes, but as far as I know, you can't make an editable ALV with CL_SALV_TABLE.
2020 Nov 26 7:52 AM
kerem.koseoglu thanks, I didn't know about it: I mostly used the fm out of habit and the class seemed way nicer. I've just discovered this is actually a well-known and long standing issue.
2020 Nov 26 7:53 AM
kerem.koseoglu about CL_SALV_TABLE editable... yes and no... (thanks to naimesh.patel )
afsane_salehi you should enquire your manager and ask why he wants this way, just to understand if there is any (i doubt!) real reason behind his requests or whatelse.
If a method is obsolete and there is no reason to use it, your "duty" is also to investigate why.
Or you'll be nothing than a "button pusher" instead of a developer.
2020 Nov 26 7:59 AM
Thanks everybody c5e08e0478aa4727abc4482f5be390b2 kerem.koseoglu
But again, I did not know what to do
Thank you for your help And that because I am a novice,
thank you for explaining in detail and elementary
2020 Nov 25 8:51 PM
Your manager told you to not use OCCURS and he/she's right.
But don't use the HEADER LINE, it's obsolete too.
*DATA : IT_MSEG TYPE TABLE OF TY_MSEG WITH HEADER LINE, <======== BAD :(
DATA : IT_MSEG TYPE TABLE OF TY_MSEG, "<======== GOOD :)
WA_MSEG TYPE TY_MSEG.
...
APPEND WA_MSEG TO IT_MSEG.
...
LOOP AT IT_MSEG INTO WA_MSEG. "(nowadays, prefer REFERENCE INTO ...)
...
ENDLOOP.
2020 Nov 26 4:59 AM
It has been stated that REFERENCE INTO has a lower performance than ASSIGNING. Check: https://github.com/SAP/styleguides/issues/115
2020 Nov 26 7:46 AM
thank you sandra.rossi
Only I did not understand this part,
APPEND WA_MSEG TO IT_MSEG....LOOPAT IT_MSEG INTO WA_MSEG."(nowadays, prefer REFERENCE INTO ...)...ENDLOOP.
WA_MSEG IS empty, why should I append it And, 😮
thank you for editing the code for me Also, :)))))))
please explain the reason why occurs 0 is not good
2020 Nov 26 7:56 AM
This section is being challenged.
FIELD-SYMBOL
s seem to be considerably faster when iterating internal tables, such that the recommendation to useREF TO
for these cases may worsen performance.
LOOP AT components REFERENCE INTO DATA(component).
instead of the equivalent
" anti-pattern
LOOP AT components ASSIGNING FIELD-SYMBOL(<component>).
And the fact is that "considerably faster" (around 20%) is just about few microseconds. So it applies only to very rare high-performance-sensitive algorithms, and it remains tiny compared to slow ABAP statements like database access.
2020 Nov 26 7:57 AM
afsane_salehi OCCURS 0 is marked obsolete in the ABAP documentation for 20 years. It creates a header line too. Header lines are prone to errors.
2020 Nov 26 8:26 AM
afsane_salehi concerning APPEND WA_MSEG, you say it's empty but in my example I omitted lines before (the ellipsis) so WA_MSEG should not be empty of course. I indicated the syntax of statements to help you, because you seem to program using the header lines which are obsolete (APPEND IT_MSEG was a valid syntax in the past, IT_MSEG being at the same time a structure and an internal table, which is confusing).
2020 Nov 26 8:27 AM
DEAR Sandra Rossi
Thank you very much for your explanation
But unfortunately, I have not yet come up with a solution. :(((
If you help me in this regard, I would be grateful :)))
2020 Nov 26 8:58 AM
What is your current issue? I think I have answered all the parts of your question. Please explain in details.
2020 Nov 26 9:20 AM
Thank you so much that I can not say how Sandra Rossi
Your explanation is good, but maybe because I just met AbAp last week, I'm still stuck
Honestly, I did not understand where I should use APPEND and LOOP AT
That's why I asked you to edit the code so I would understand
Is there another way of communication we have? Of course, if you wish
2020 Nov 26 1:35 PM
In your case, you don't need APPEND ... TO itab and LOOP AT itab ... because SELECT ... INTO TABLE itab ... is sufficient for your short example, but you'll need them in the future, it was just to explain you how to work with WA_ITAB, and not with an internal table with a header line. Sorry for the confusion.
*DATA : IT_MSEG TYPE TABLE OF TY_MSEG WITH HEADER LINE, <======== BAD :(
DATA : IT_MSEG TYPE TABLE OF TY_MSEG, "<======== GOOD :)
WA_MSEG TYPE TY_MSEG.
2020 Nov 26 2:02 PM
sandra.rossi you feel the difference when working with millions of records; when working with BPC, for example. I did for sure 😉
2020 Nov 29 7:28 AM
DEAR sandra.rossi
Thank you very much for your excellent explanation.
In general, I have a big problem with the internal table that is going to be used in the catalog field.
I read and searched a lot about it, but unfortunately I still have a problem.
When I use the internal table according to the same definition that you gave, it gives me the same error. I would love to understand everything accurately and correctly now that I am moving forward from zero.
Now, I have given the change you said in the same example that I sent to you, but it still gives the same error, can you help me?
2020 Nov 29 7:31 AM
You say "I still have a problem". What error message? What code? What line has the error?
2020 Nov 30 8:23 AM
DEAR sandra.rossi
Thank you for wanting to help me and for paying attention to what I have to say
When I run the program.
It gives me exactly the catalog field error (NO_FIELDCATALOG_AVAILABLE).
Of course, I left a line for you in the code I posted,
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.
first I add it, then I execute it, but it gives the same error again.
I do not know the internal table that I define and use in my 'REUSE_ALV_FIELDCATALOG_MERGE' should be such that there is no problem and my FIELDCATALOG is full.
2020 Nov 30 8:51 AM
Sorry I still don't understand. Probably a newbie error 😉 . Please attach the whole code as a text file.
2020 Nov 30 5:33 PM
DEARE sandra.rossi
I'm ashamed of bothering you
I run this code with an error I see the attached photo
TYPE-POOLS :SLIS.
TYPES : BEGIN OF TY_MSEG ,
MANDT LIKE MSEG-MANDT,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
ZEILE LIKE MSEG-ZEILE,
END OF TY_MSEG .
DATA : IT_MSEG TYPE TABLE OF TY_MSEG WITH HEADER LINE,
WA_MSEG TYPE TY_MSEG.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA: gv_progname LIKE sy-repid.
gv_progname = sy-repid.
SELECT-OPTIONS : S_MBLNR FOR IT_MSEG-MBLNR ,
S_MJAHR FOR IT_MSEG-MJAHR .
START-OF-SELECTION .
PERFORM GET_DATA .
PERFORM VALIDATE_FIELDCAT .
PERFORM DISPLAY_DATA .
FORM GET_DATA .
SELECT MSEG~MANDT
MSEG~MBLNR
MSEG~MJAHR
MSEG~ZEILE
INTO TABLE IT_MSEG
FROM MSEG
WHERE MBLNR IN S_MBLNR AND MJAHR IN S_MJAHR .
ENDFORM .
FORM VALIDATE_FIELDCAT .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = gv_progname
I_INTERNAL_TABNAME = 'IT_MSEG'
I_INCLNAME = gv_progname
CHANGING
CT_FIELDCAT = IT_FCAT[].
ENDFORM.
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = gv_progname
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_MSEG.
ENDFORM .
2020 Nov 30 7:34 PM
We're telling you to not use OCCURS 0, and to not use WITH HEADER LINE. They are prone to errors. i.e. you get this kind of error that you don't understand and make you lose a lot of time.
Stop using it and the error disappears.
For information, the error is that, an internal table with a header line, means two different things, either a structure (the header line) or an internal table. If you write IT_FCAT[], it means the internal table, otherwise if it's written IT_FCAT it depends a lot:
- If it's passed as argument of an EXPORTING/IMPORTING/CHANGING parameter it means the header line
- Otherwise, if it's passed as argument of a TABLES parameter it means the internal table
- Etc.
2020 Dec 01 5:22 AM
HI sandra.rossi
thank you According to you, "WITH HEADER LINE, I commented and ran the program again, but I still have the same error
TYPE-POOLS :SLIS.
TYPES : BEGIN OF TY_MSEG ,
MANDT LIKE MSEG-MANDT,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
ZEILE LIKE MSEG-ZEILE,
END OF TY_MSEG .
DATA : IT_MSEG TYPE TABLE OF TY_MSEG, "WITH HEADER LINE,
WA_MSEG TYPE TY_MSEG.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA: gv_progname LIKE sy-repid.
gv_progname = sy-repid.
SELECT-OPTIONS : S_MBLNR FOR WA_MSEG-MBLNR ,
S_MJAHR FOR WA_MSEG-MJAHR .
START-OF-SELECTION .
PERFORM GET_DATA .
PERFORM VALIDATE_FIELDCAT .
PERFORM DISPLAY_DATA .
FORM GET_DATA .
SELECT MSEG~MANDT
MSEG~MBLNR
MSEG~MJAHR
MSEG~ZEILE
INTO TABLE IT_MSEG
FROM MSEG
WHERE MBLNR IN S_MBLNR AND MJAHR IN S_MJAHR .
ENDFORM .
FORM VALIDATE_FIELDCAT .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = gv_progname
I_INTERNAL_TABNAME = 'IT_MSEG'
I_INCLNAME = gv_progname
CHANGING
CT_FIELDCAT = IT_FCAT[].
ENDFORM.
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = gv_progname
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_MSEG.
ENDFORM .
2020 Nov 26 4:58 AM
Try this:
it_mseg TYPE STANDARD TABLE OF ty_mseg
WITH KEY mblnr mjahr zeile.
2020 Nov 26 7:42 AM
2020 Nov 26 8:23 AM
DEAR kerem.koseoglu
He wants me to know all the ways
I myself want to understand the concepts step by step now that I have started from the beginning And grow from a solid foundation
2020 Dec 01 7:37 AM
The run time error NO_FIELDCATALOG_AVAILABLE may happen when it's called by REUSE_ALV_FIELDCATALOG_MERGE.
The issue with REUSE_ALV_FIELDCATALOG_MERGE is that it's very old, and if you use I_INTERNAL_TABNAME, and want to use modern syntax (no header line), the only possibility is to declare the structure via a variable (DATA), not a type, and you must pass the name of that structured variable to the parameter I_INTERNAL_TABNAME of REUSE_ALV_FIELDCATALOG_MERGE.
Another solution is to define the structure in the DDIC, and you don't need to use neither REUSE_ALV_FIELDCATALOG_MERGE, nor I_INTERNAL_TABNAME, unless you want to adapt the returned catalog.
Of course, you will avoid a lot of pain if you use CL_SALV_TABLE instead of the obsolete REUSE_* and CL_GUI_ALV_GRID.
Working code (note that LIKE used with a DDIC type is obsolete, you should use a variable - WA_DUMMY_MSEG below):
DATA: WA_DUMMY_MSEG TYPE MSEG.
DATA: BEGIN OF WA_MSEG ,
MANDT LIKE WA_DUMMY_MSEG-MANDT,
MBLNR LIKE WA_DUMMY_MSEG-MBLNR,
MJAHR LIKE WA_DUMMY_MSEG-MJAHR,
ZEILE LIKE WA_DUMMY_MSEG-ZEILE,
END OF WA_MSEG .
DATA : IT_MSEG LIKE TABLE OF WA_MSEG.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV .
DATA: gv_progname LIKE sy-repid.
SELECT-OPTIONS : S_MBLNR FOR WA_MSEG-MBLNR ,
S_MJAHR FOR WA_MSEG-MJAHR .
START-OF-SELECTION .
gv_progname = sy-repid.
PERFORM GET_DATA .
PERFORM VALIDATE_FIELDCAT .
PERFORM DISPLAY_DATA .
FORM GET_DATA .
SELECT MSEG~MANDT
MSEG~MBLNR
MSEG~MJAHR
MSEG~ZEILE
INTO TABLE IT_MSEG
FROM MSEG
WHERE MBLNR IN S_MBLNR AND MJAHR IN S_MJAHR .
ENDFORM .
FORM VALIDATE_FIELDCAT .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = gv_progname
I_INTERNAL_TABNAME = 'WA_MSEG'
I_INCLNAME = gv_progname
CHANGING
CT_FIELDCAT = IT_FCAT.
ENDFORM.
FORM DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = gv_progname
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_MSEG.
ENDFORM .
2020 Dec 01 7:45 AM
If I remember correctly, even this piece
DATA: BEGIN OF WA_MSEG ,
MANDT TYPE MSEG-MANDT,
MBLNR TYPE MSEG-MBLNR,
MJAHR TYPE MSEG-MJAHR,
ZEILE TYPE MSEG-ZEILE,
END OF WA_MSEG .
Should become
DATA: BEGIN OF WA_MSEG ,
MANDT LIKE MSEG-MANDT,
MBLNR LIKE MSEG-MBLNR,
MJAHR LIKE MSEG-MJAHR,
ZEILE LIKE MSEG-ZEILE,
END OF WA_MSEG .
I found some kind of issue in the past declaring them as TYPE, but maybe i'm confusing the issues.
PS.
Shouldn't you pass the I_STRUCTURE instead of I_INTERNAL_TABLE? (not access to SAP systema atm)
CALLFUNCTION'REUSE_ALV_FIELDCATALOG_MERGE'EXPORTING
I_PROGRAM_NAME = gv_progname
I_INTERNAL_TABNAME ='WA_MSEG'
I_INCLNAME = gv_progname
CHANGING
CT_FIELDCAT = IT_FCAT.
2020 Dec 01 9:48 AM
You are the best of the best.
Your REGURDS were great.
My problem is completely solved.
Thank you for your patient response.
Just a question now, isn't the one WA_MSEG defined a structure? But despite the fact that we said in the "REUSE_ALV_FIELDCATALOG_MERG", Internal Table, but it was OK !!!! 😮
2020 Dec 01 9:51 AM
DEAR simone.milesi
I also converted the type to like But for me,
the question is that if WA_MSEG are not a structure?, then why did we see it as an internal table?
2020 Dec 01 9:55 AM
Yes, WA_MSEG is a structured variable. It's just that parameter I_INTERNAL_TABNAME of REUSE_ALV_FIELDCATALOG_MERGE works well with a structured variable too. Thanks to this strange feature, you may avoid using obsolete ABAP declarations.
2020 Dec 01 10:17 AM
2020 Dec 01 10:53 AM