How to pass single-column table to AMDP method? - abap

I need to pass a table with a single column to an AMDP method which throws the error, the other parameters go fine:
TYPES: BEGIN OF s_so_i,
parent_key TYPE snwd_so_i-parent_key,
product_guid TYPE snwd_pd-node_key,
node_key TYPE snwd_so_i-node_key,
END OF s_so_i.
TYPES: BEGIN OF s_product,
product_guid TYPE snwd_pd-node_key,
category TYPE snwd_pd-category,
END OF s_product.
TYPES: tt_product TYPE STANDARD TABLE OF s_product,
tt_so TYPE STANDARD TABLE OF snwd_node_key, "<-- error
tt_so_i TYPE STANDARD TABLE OF s_so_i.
How should I define it?

instead of using snwd_node_key I can suggest you to use EGUID_S.
EGUID_S is a structure with only including a single column with RAW16 as SYSUUID
instead of
tt_so TYPE STANDARD TABLE OF snwd_node_key,
use
tt_so TYPE STANDARD TABLE OF EGUID_S,

Adding this solved the problem:
TYPES: BEGIN OF s_so,
so_guid TYPE snwd_so-node_key,
END OF s_so.
TYPES: tt_product TYPE STANDARD TABLE OF s_product,
tt_so_i TYPE STANDARD TABLE OF s_so_i,
tt_so TYPE STANDARD TABLE OF s_so. <--
So it seems the table type must point to a structure type.

Related

postgresql changing column type from array to integer throwing casting error

I am changing the postgresql column data type from integer[] to integer, while executing below query,
alter table contact_type alter column is_delete set data type integer USING is_delete::integer
i am getting below error
ERROR: cannot cast type integer[] to integer
LINE 1: ...umn is_delete set data type integer USING is_delete::integer
^
SQL state: 42846
Character: 86
but when tried to change datatype from varchar[] to char, below query works fine
alter table contact_type alter column ct_type set data type varchar
i have referred this link so link but it is not working for converting array to normal data type..
Edit :- it is empty table without any data...
You need to pick the array element that you want to use. You can't convert e.g. 42 integers to a single one.
E.g. if you want to use the first element of the array:
alter table contact_type
alter column is_delete
set data type integer USING is_delete[1];
But a column named is_delete should probably be a boolean rather than an integer.

Set parameter name as an internal table name

I wanted to know if it is possible to make the input parameter name as an internal table.
Please have a look in the snippet of the code. In this report I am trying to take p_dbtab as a table name then make an internal table i_temp of the type p_dbtab.
REPORT ZPRACTICDYNAMIC.
SELECTION-SCREEN BEGIN OF BLOCK 1.
PARAMETERS:
p_dbtab TYPE tabname DEFAULT 'FARR_D_FULFILLMT' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK 1.
DATA: it_tab TYPE STANDARD TABLE OF p_dbtab.
this will work:
data: rt_data type REF TO data.
PARAMETERS: p_dbtab TYPE tabname DEFAULT 'FARR_D_FULFILLMT' OBLIGATORY.
FIELD-SYMBOLS: <t_data> type any TABLE.
CREATE DATA rt_data type STANDARD TABLE OF (p_dbtab).
assign rt_data->* to <t_data>.

How to declare table type inside structure?

In order to achieve my smartform, I'm supposed to declare a table within a structure. I tried this but it's not working:
TYPES: t_qase2 TYPE TABLE OF qase.
TYPES:
BEGIN OF ty_itab.
pruefer type qase-pruefer.
zeiterstl type qase-zeiterstl.
* ......(other fields)
ty_qase2 type t_qase2.
INCLUDE STRUCTURE s_f800komp.
TYPES END OF ty_itab.
To declare a table in a structure you simply give a table type with non-unique key to one of the fields:
TYPES: myTableType TYPE TABLE OF string WITH NON-UNIQUE DEFAULT KEY.
TYPES: BEGIN OF ty_itab,
pruefer type qase-pruefer,
zeiterstl type qase-zeiterstl,
myTable type myTableType, "Table is here
ty_qase2 type t_qase2.
INCLUDE STRUCTURE s_f800komp.
TYPES: END OF ty_itab.
Also notice that you end every line with a dot. In this case you have to use ,
Besides the variant proposed by previous answerer, there is variant of table declaration inside structure in an explicit way:
TYPES: BEGIN OF ty_itab,
pruefer TYPE qase-pruefer,
zeiterstl TYPE qase-zeiterstl,
myTable TYPE TABLE OF string WITH NON-UNIQUE DEFAULT KEY,
ty_qase2 TYPE t_qase2.
INCLUDE STRUCTURE s_f800komp.
TYPES: END OF ty_itab.

What is wrong with the following ABAP code

REPORT zbc400_figure157.
TYPES: BEGIN OF t_conn,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
END OF t_conn.
DATA:
conn_list LIKE STANDARD TABLE OF t_conn,
startline LIKE sy-tabix,
BEGIN OF wa_travel,
dest TYPE spfli-cityto,
cofl_list LIKE conn_list,
END OF wa_travel,
travel_list LIKE SORTED TABLE OF wa_travel WITH UNIQUE KEY dest.
FIELD-SYMBOLS:
<fs_conn> TYPE t_conn,
<fs_conn_int> TYPE t_conn,
<fs_travel> TYPE wa_travel.
PARAMETERS pa_start TYPE spfli-cityfrom DEFAULT 'FRANKFURT'.
SELECT carrid cityfrom cityto
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE conn_list.
SORT conn_list BY cityfrom cityto ASCENDING AS TEXT.
** build up nested table.
LOOP AT conn_list ASSIGNING <fs_conn> WHERE cityfrom = pa_start.
CLEAR wa_travel.
wa_travel-dest = <fs_conn>-cityto.
READ TABLE conn_list
WITH KEY cityfrom = wa_travel-dest
TRANSPORTING NO FIELDS
BINARY SEARCH.
startline = sy-tabix.
LOOP AT conn_list ASSIGNING <fs_conn_int>
FROM startline.
IF <fs_conn_int>-cityfrom <> wa_travel-dest.
EXIT.
ENDIF.
APPEND <fs_conn_int> TO wa_travel-cofl_list.
ENDLOOP.
SORT wa_travel-cofl_list BY cityto carrid ASCENDING AS TEXT.
INSERT wa_travel INTO TABLE travel_list.
ENDLOOP.
Error: Field "T_CONN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement . . . . . . . . . .
We declare an inner table COFL_LIST and an outer table TRAVEL_LIST with corrosponding work areas. An internal table CONN_LIST buffers all of the flight connections and sorts them.
The program uses 3 tables, inner table, outer table and an internal table.
I made the changes in the program as suggested by LPK:
conn_list TYPE STANDARD TABLE OF t_conn,
However, now the problem is in line:
FIELD-SYMBOLS:
<fs_conn> TYPE t_conn,
<fs_conn_int> TYPE t_conn,
<fs_travel> TYPE wa_travel.
Error: The type "WA_TRAVEL" is unknown.
In the program wa_travel variable is already defined in it's BEGIN OF wa_travel and END OF wa_travel block. Why can't the system pick this up?
This line is wrong:
conn_list LIKE STANDARD TABLE OF t_conn,
T_CONN is a type and therefore you have to use TYPE instead of LIKE.
You can find an explanation about the difference here.
The declaration is not correct...
FIELD-SYMBOLS:
TYPE t_conn,
TYPE t_conn,
TYPE wa_travel.
Should be
FIELD-SYMBOLS:
TYPE t_conn,
TYPE t_conn,
LIKE wa_travel.
You need to check with the link provided in the previous answer... or you can use the following from the Help Portal on TYPE & LIKE

Passing user defined TABLE type to stored Oracle function

I have an oracle function defined as:
FUNCTION SELECTINBOX (FA_FROMUSERLIKE IN PKGSMSTYPES.MAXVARCHAR2_T DEFAULT NULL ,
FA_INBOXOWNER IN PKGSMSTYPES.MAXVARCHAR2_T,
FA_A_URGENCY IN G_INTARRAY_TBL DEFAULT NULL ,
FA_PAGENO IN NUMBER DEFAULT 1
) RETURN G_SMSNOTES_TBL;
where G_INTARRAY_TBL is defined as,
create or replace
TYPE G_INTARRAY_TBL AS TABLE OF NUMBER;
I am building the query using eclipselink. The query works fine if I hardcode G_INTARRAY_TBL as null in the query string but if I try to pass a List of BigDecimals to it, I get an error,
Internal Exception: java.sql.SQLException: Invalid column type
Error Code: 17004
Include your code for your query.
You need to use a PLSQLStoredFunctionCall (#NamedPLSQLStoredFunctionQuery) for this. You also need to mirror the PLSQL TABLE type with a VARRAY type.
See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/PLSQLStoredFunction