3 weeks ago
Hi all,
I have a problem with a method call that has me, to say the least, perplexed.
The method is very simple. It receives a single parameter (table name) and returns a date:
METHOD ultima_fecha_pbi.
"--------------------------------------------------------------------*
" CLASS-METHODS GET_ULTIMA_FECHA_PBI
" IMPORTING
" !TABLA TYPE ANY
" returning
" VALUE(ULTIMA_FECHA) TYPE LASDA .
"--------------------------------------------------------------------*
SELECT SINGLE ultima_fecha FROM zlog_tablas_pbi
WHERE tabla = @tabla "<------ Table name
INTO @ultima_fecha. "<------ Date
ENDMETHOD.
When called from a simple test program (no includes), the method works perfectly, i.e., returns the data as expected.
CONSTANTS c_tabla_sap TYPE string VALUE 'ZLISFACT'. "<-- Table name
DATA g_ultima_fecha TYPE dats. "<-- date
PERFORM buscar_ultima_fecha USING c_tabla_sap
CHANGING g_ultima_fecha.
"-------------------------------------------------------------------
FORM buscar_ultima_fecha USING nombre_tabla TYPE any
CHANGING p_ultima_fecha TYPE dats.
p_ultima_fecha = zcl_pbi=>ultima_fecha_pbi( tabla = nombre_tabla ).
ENDFORM.
If I check the data just after the SELECT (using debug) I get:
TABLA = ZLISFACT (Table name - Data type CString{8})
HEX = 5A004C00490053004600410043005400
So far, so good but, if I call exactly the same method with the same parameters (and using exactly the same FORM) from a report program with includes, the SELECT returns SY-SUBRC 4, even though the data (seen using debug) appears to be the same:
TABLA = ZLISFACT
HEX = 5A004C00490053004600410043005400
Any ideas?
TIA,
Luis
Request clarification before answering.
All,
Ok. For reasons unknown, this table had two (02) key fields: The table name (tabla TYPE TABLENAME_TEXT) and a TIMESTAMP field. BUT, it just happens that the TIMESTAMP field was written / updated ALWAYS as blank (please, don’t ask), so the SELECT was made using only the table name in the WHERE clause.
So, after a little digging around and seeing that no one else was using this table, it was decided to remove this column and adjust the table with SE14. Problem solved!! The record appeared “magically”…
I’m going to file this between “Twilight Zone” and The Journal of Irreproducible Results and consider the problem closed (juggling a lot of programs right now, so I can’t invest more time on this thing).
Thanks to all of you for your comments and help. Really appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sandra:
I would have loved to know the cause of this problem. I tried different approaches, including performing a `SELECT * FROM PROBLEM_TABLE INTO @DATA(itab)` just before the method’s `SELECT`, but the desired record did not appear.
The use of SE14 was unrelated to the issue. Unfortunately, work pressures prevent me from spending more time solving this mystery.
Best Regards,
Luis
I guess you have here a problem with mutable variables.
When I look at the code it is very inconsistent with the use of global variables, static methods and performs.
Why you don't try to clean code this.
Maybe it will also help, if we see a bit more from the code, especially the second call, where you get the differing results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
45 | |
9 | |
8 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.