The declaration of the field-symbol is done incorrectly? - abap

I am having some trouble with activating my program. The idea is that when activating the program I get the below error as shown in the Figure. The error tells me that in line 577 instead of gty_crc_ is expected ty_chck-.
The code for the upper figure is as shown:
FORM cm_show
USING
civ_matnr TYPE matnr
civ_charg TYPE charg_d.
* <--- BOC
DATA: lt_crc_list TYPE STANDARD TABLE OF zqm_s_crc_list.
FIELD-SYMBOLS: <lfs_crc_l2> TYPE gty_crc_list.
* ---> EOC
CONSTANTS: lc_x TYPE xfeld VALUE 'X'.
DATA:
ls_charg_crc LIKE LINE OF gt_charg_crc,
* ls_crc_list LIKE LINE OF gt_crc_list.
ls_crc_list LIKE LINE OF lt_crc_list.
The code that I have for the gty_crc_list is as below:
TYPES: BEGIN OF gty_crc_list,
pruef TYPE zqmkzpruef,
qmnum TYPE qmnum,
qmart TYPE zqm_crc_typ,
qmtxt TYPE zqm_crc_titel,
referralqp TYPE zreferralqp,
referralqp_txt TYPE zreferralqp_txt,
sttxt TYPE sttxt,
fecod TYPE fecod,
fectx TYPE qtxtcdgrfe,
objnr TYPE j_objnr,
END OF gty_crc_list,
gtt_crc_list TYPE STANDARD TABLE OF gty_crc_list.
Can anyone tell me if the problem is in the syntax or it has something to do with the naming convention for the tables?
Thank you all in advance!

It's gty_crc_list in an include included before the FORM cm_show include?
Error:
Line 10: INCLUDE ZPROGRAM1_F01 <-- FORM cm_show
Line 11: INCLUDE ZPROGRAM1_TOP <-- GTY_CRC_LIST declaration.
Correct:
Line 10: INCLUDE ZPROGRAM1_TOP <-- GTY_CRC_LIST declaration.
Line 11: INCLUDE ZPROGRAM1_F01 <-- FORM cm_show

Related

Error : Field "S_MARA-MATNR" is unkown during FOR statement

DATA: t_mara type STANDARD TABLE OF mara WITH EMPTY KEY.
DATA(t_data1) = VALUE ty_data( FOR s_mara IN t_mara ( s_mara–matnr ) ).
I am trying to implement a similar code using FOR statement but I am getting an error that the field is unknown in the work area even though it would be declared inline.
Can you please let me know what went wrong? This is my first time I am facing this error on FOR loop.
Not sure because you are not providing too much detail but try this:
DATA t_mara type STANDARD TABLE OF mara WITH EMPTY KEY.
DATA(t_data1) = VALUE ty_data( FOR s_mara IN t_mara ( matnr = s_mara-matnr ) ).

Cannot create field catalog with REUSE_ALV_FIELDCATALOG_MERGE

I'm new to ABAP, and I'm trying to build a field catalog using the REUSE_ALV_FIELDCATALOG_MERGE function module. This function module exits with sy-subrc value 1 ("Inconsistent interface") and a message dialog appears saying that the field catalog couldn't be build.
My code is the same as the examples found online. Maybe I missed something.
My program consists of a TOP include, a FORMS include and the main module:
FORMS include:
FORM DISPLAY_WITH_ALV_LIST.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'it_report'
I_INCLNAME = sy-repid
CHANGING
CT_FIELDCAT = it_fldcat.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
IT_FIELDCAT = it_fldcat
TABLES
T_OUTTAB = it_report.
ENDFORM.
FORM ZSELECT.
SELECT VBELN ERDAT ERNAM
FROM VBAK
INTO CORRESPONDING FIELDS OF TABLE it_report
WHERE ERDAT IN S_ERDAT
AND ERNAM IN S_ERNAM.
ENDFORM.
TOP include:
TYPE-POOLS: slis.
TABLES VBAK.
DATA: BEGIN OF it_report OCCURS 0,
VBELN LIKE VBAK-VBELN,
ERDAT LIKE VBAK-ERDAT,
ERNAM LIKE VBAK-ERNAM,
END OF it_report.
DATA it_fldcat TYPE slis_t_fieldcat_alv.
Main module:
REPORT ZMLA_EXO1.
INCLUDE ZMLA_EXO1_TOP.
INCLUDE ZMLA_EXO1_SCREEN.
INCLUDE ZMLA_EXO1_FORM.
INITIALIZATION.
AT SELECTION-SCREEN.
START-OF-SELECTION.
PERFORM ZSELECT.
PERFORM DISPLAY_WITH_ALV_LIST.
END-OF-SELECTION.
I would advise using the "SALV" class. It's pretty straight forward, in your case it would look like this:
DATA: go_salv_table TYPE REF TO cl_salv_table.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = go_salv_table
CHANGING
t_table = it_report.
go_salv_table->display( ).
If you still insist on using the function module (FM) REUSE_ALV_FIELDCATALOG_MERGE, and generate field catalog from internal table, then these conditions must be observed:
Your internal table with the data to be displayed has to be declared with the word "OCCURS" (not a must to use addition "WITH HEADER LINE").
Fields of the internal table have to be declared using "LIKE". It will not work if you use "TYPE" to declare the fields.
No line in your program should exceed 72 characters. Otherwise a short dump will be generated with the exception cx_sy_read_src_line_too_long since the FM has to scan your program code looking for the internal table definition.
In short, it's an old FM with a lot of problems.

Syntax error "Field "L_TABDEF–TLTYPE" is unknown" in Smart Form

I have defined local variables in a program line in SMARTFORMS but it seems that even it is locally declared within the program line node, it does not see the variables.
Error shown below.
Field "L_TABDEF–TLTYPE" is unknown. It is neither in one of the
specified tables nor defined by a "DATA" statement. "DATA" state
FIELD-SYMBOLS: <f_tab> TYPE tsftabdef.
DATA: l_tabdef TYPE ssftabdef , " Work Area for the Table
t_ltypes TYPE tsfltype , " Table – Line types
l_ltypes TYPE ssfltype , " Work Area for the table
t_colinfo TYPE tsfcolinfo , " Table – Columns
l_colinfo TYPE ssfcolinfo , " Work area for the table
t_border TYPE tsfctaba , " Tables – Borders
l_border TYPE ssfctaba . " Work Area for the border
ASSIGN ('(SAPLSTXBC)TABDEFS') TO <f_tab>.
* Table definition table
LOOP AT <f_tab> INTO l_tabdef.
LOOP AT l_tabdef–tltype INTO l_ltypes WHERE linetype = 'LINE'.
LOOP AT l_ltypes–tcolinfo INTO l_colinfo.
LOOP AT l_colinfo-borders INTO l_border.
CLEAR l_border-intensity.
l_border-fillcolor-red = '255'.
l_border-fillcolor-green = '000'.
l_border-fillcolor-blue = '000'.
l_border-fillcolor-used = 'X'.
l_border-cfillcolor-color = 'X'.
l_border-cfillcolor-xred = 'FF'.
l_border-cfillcolor-xgreen = '00'.
l_border-cfillcolor-xblue = '00'.
MODIFY l_colinfo-borders FROM l_border.
ENDLOOP.
MODIFY l_ltypes-tcolinfo FROM l_colinfo.
ENDLOOP.
MODIFY l_tabdef-tltype FROM l_ltypes.
ENDLOOP.
MODIFY <f_tab> FROM l_tabdef.
ENDLOOP.
What am I missing here?
In l_tabdef–tltype, you are confused by the dash character which is in fact the invalid Unicode character EN DASH U+2013, so it's not recognized as the "structure component selector" (i.e. the dash character U+002D) and the compiler considers the whole name as referring to a classic data object, not a structure component.
Probably the error originates from a copy/paste from your favorite Text Processing software.
Solution: please retype "-" in l_tabdef–tltype.
PS: thank you for having provided this Minimal, Complete, and Verifiable example otherwise it would have been impossible to troubleshoot the issue!

Crash "Field symbol has not yet been assigned" when calling REUSE_ALV_GRID_DISPLAY

While displaying an ALV I get a crash report when executing the program. To create an ALV I have followed a few tutorials and stuff and at the moment it looks like this:
TYPE-POOLS: slis.
*build field catalog
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
repid TYPE sy-repid.
REFRESH it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Table ID'.
wa_fieldcat-fieldname = 'table_id'.
wa_fieldcat-tabname = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen = '18'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Table Description'.
wa_fieldcat-fieldname = 'table_description'.
wa_fieldcat-tabname = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen = '40'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-reptext_ddic = 'Numer of Records Found'.
wa_fieldcat-fieldname = 'nr_of_records'.
wa_fieldcat-tabname = 'lt_where_used_data_of_coll'.
wa_fieldcat-outputlen = '30'.
APPEND wa_fieldcat TO it_fieldcat.
*pass data and field catalog to ALV function module
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = repid
it_fieldcat = it_fieldcat
i_structure_name = 'lty_where_used_data_of_coll'
TABLES
t_outtab = lt_where_used_data_of_coll.
'lt_where_used_data_of_coll' is my local table that I have already filled with a working function earlier in my program. This function works and I have tested it and the table fills itself with data. My next step was displaying this data to the end user. The error report I receive when executing this program is:
Short text: Field symbol has not yet been assigned.
What happened?:
Error in the ABAP Application Program.
The current ABAP program "SAPLSLVC" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis:
You attempted to access an unassigned field symbol
(data segment "-1").
Trigger Location of Runtime Error:
Program SAPLSLVC
Include LSLVCF36
Row 3,273
Module type (FORM)
Module Name FILL_DATA_TABLE
I really don't know how to start finding my mistake. It seems like it runs bad when calling a function from ABAP itself.
Any help is much appreciated.
EDIT: As was suggested I implemented another way of displaying an ALV that can be found below. This way works fine and gives no errors. Question still remains why the older method does give me an error.
I replaced the entire block of code above with this:
DATA alv TYPE REF TO cl_salv_table. DATA message TYPE REF TO cx_salv_msg.
*initialize ALV
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table = lt_where_used_data_of_coll ).
CATCH cx_salv_msg INTO message.
" error handling
ENDTRY.
*display ALV
alv->display( ).
why the older method does give me an error
Field catalog names are case sensitive. Capitalize every fieldname and tabname value and see if the error's still there. Also make sure that the names match those of your internal table lt_where_used_data_of_coll

PL/SQL function return type integer : Invalid Identifier

I have a function called get_pid in a file called func.sql . The function get_id takes an
input: given_price Parts.price%type and returns an integer.
To call this function, I created a new file called main.sql. Then I login to sqlplus and I call main in this way:
SQL> #Q1_main
select get_pid(400) from dual
*
ERROR at line 1:
ORA-00904: "GET_PID": invalid identifier
Am I calling the function properly? What could possibly be wrong, I looked at the other questions posted about this topic, but I can't figure out what I am doing wrong.
Try to inform the name of the scheme where are your function.
for example, the username (schema) is dev, then you have to try like this.
select dev.get_pid(400) from dual.
when you are on prompt you always have to use the scheme name "." your function/procedure.