‎2007 May 08 3:26 PM
Have a doubt about declaration statements.
This code works:
TYPES:
BEGIN OF ty_bapidata,
headerdata TYPE bapi_incinv_create_header,
docnumber TYPE bapi_incinv_fld-inv_doc_no,
fiscalyear TYPE bapi_incinv_fld-fisc_year,
itemdata TYPE bapi_incinv_create_item
OCCURS 1000,
glaccountdata TYPE bapi_incinv_create_gl_account
OCCURS 1000,
taxdata TYPE bapi_incinv_create_tax
OCCURS 1000,
END OF ty_bapidata,
ty_tbl_bapidata TYPE STANDARD TABLE OF ty_bapidata.I'd like to declare the same but not using OCCURS clause since it's obsolete.
I've tried these both, but they give errors:
<b>Alternative 1:</b>
TYPES:
BEGIN OF ty_bapidata,
headerdata TYPE bapi_incinv_create_header,
docnumber TYPE bapi_incinv_fld-inv_doc_no,
fiscalyear TYPE bapi_incinv_fld-fisc_year,
itemdata TYPE TABLE OF bapi_incinv_create_item,
glaccountdata TYPE TABLE OF bapi_incinv_create_gl_account,
taxdata TYPE TABLE OF bapi_incinv_create_tax,
END OF ty_bapidata,
ty_tbl_bapidata TYPE STANDARD TABLE OF ty_bapidata.This gives the error <b>"You cannot use generic type definitions within structures."</b>
<b>Alternative 2:</b>
TYPES:
ty_tbl_item TYPE TABLE OF bapi_incinv_create_item,
ty_tbl_gl_account TYPE TABLE OF bapi_incinv_create_gl_account,
ty_tbl_tax TYPE TABLE OF bapi_incinv_create_tax,
BEGIN OF ty_bapidata,
headerdata TYPE bapi_incinv_create_header,
docnumber TYPE bapi_incinv_fld-inv_doc_no,
fiscalyear TYPE bapi_incinv_fld-fisc_year,
itemdata TYPE ty_tbl_item,
glaccountdata TYPE ty_tbl_gl_account,
taxdata TYPE ty_tbl_tax,
END OF ty_bapidata,
ty_tbl_bapidata TYPE STANDARD TABLE OF ty_bapidata.This gives the error <b>"TY_TBL_ITEM" is a generic type. A type reference is possible only for field symbols and FORM parameters.</b>
I know that if I create table types in data dictionary and then use them instead, it works. But i don't wanna do that.
Is there any other alternative that i don't know <b>which is not obsolete</b>? (not interested in other "old" variants as using OCCURS).
Many thanks.
‎2007 May 08 3:44 PM
Please try adding WITH DEFAULT KEY
types:
ty_tbl_item type table of bapi_incinv_create_item
with default key,
ty_tbl_gl_account type table of bapi_incinv_create_gl_account
with default key,
ty_tbl_tax type table of bapi_incinv_create_tax
with default key.
types:
begin of ty_bapidata,
headerdata type bapi_incinv_create_header,
docnumber type bapi_incinv_fld-inv_doc_no,
fiscalyear type bapi_incinv_fld-fisc_year,
itemdata type ty_tbl_item,
glaccountdata type ty_tbl_gl_account,
taxdata type ty_tbl_tax,
end of ty_bapidata,
ty_tbl_bapidata type standard table of ty_bapidata.
Regards,
Rich Heilman
Message was edited by:
Rich Heilman
‎2007 May 08 3:33 PM
chk this
REPORT ABC.
TYPES:
BEGIN OF TY_BAPIDATA,
HEADERDATA TYPE BAPI_INCINV_CREATE_HEADER,
DOCNUMBER TYPE BAPI_INCINV_FLD-INV_DOC_NO,
FISCALYEAR TYPE BAPI_INCINV_FLD-FISC_YEAR.
TYPES : BEGIN OF ITEMDATA.
INCLUDE STRUCTURE BAPI_INCINV_CREATE_ITEM.
TYPES : END OF ITEMDATA.
TYPES : BEGIN OF GLACCOUNTDATA.
INCLUDE STRUCTURE BAPI_INCINV_CREATE_GL_ACCOUNT.
TYPES : END OF GLACCOUNTDATA.
TYPES : BEGIN OF TAXDATA.
INCLUDE STRUCTURE BAPI_INCINV_CREATE_TAX.
TYPES : END OF TAXDATA.
TYPES : END OF TY_BAPIDATA.
TYPES : TY_TBL_BAPIDATA TYPE STANDARD TABLE OF TY_BAPIDATA.
‎2007 May 08 3:36 PM
Hi,
After the types statement write this statement which declares an Inernal table
DATA: it_bapidata TYPE TABLE OF ty_bapidata WITH HEADER LINE.
‎2007 May 08 3:41 PM
Just a remark, that 'WITH HEADER LINE. ' cannot be used in ABAP Objects.
Peter
‎2007 May 08 3:45 PM
Thank you all people for quick replies
- Chandrasekhar your statement declares STRUCTURES inside the type, not internal tables.
- Mrunal as Peter points, that statement is obsolete, anyway i know how to declare a table using the type, that's not what i'm asking about.
- Rich I forgot i knew that way also, but I was not sure that's not obsolete. Isn't it? Please confirm. Many thanks.
‎2007 May 09 10:53 AM
> - Rich I forgot i knew that way also, but I was not
> sure that's not obsolete. Isn't it? Please confirm.
I checked the documentation in a NW2004s/700 system and there is no remark about this if it would be obsolete, default key is still there as available option:
It might change with 7.10 as in the SDN clubhouse video they mentioned something about multiple indexes on internal tables, but I have not much about this.
<a href="/people/community.user/blog/2007/02/19/teched-06-archive-abap-editor video</a>
Best regards,
Peter
PS: The 700 documentation:
TYPES - key
Syntax
... [UNIQUE | NON-UNIQUE] { {KEY comp1 comp2 ...}
| {DEFAULT KEY} } ... .
‎2007 May 09 10:47 PM
‎2007 May 08 3:44 PM
Please try adding WITH DEFAULT KEY
types:
ty_tbl_item type table of bapi_incinv_create_item
with default key,
ty_tbl_gl_account type table of bapi_incinv_create_gl_account
with default key,
ty_tbl_tax type table of bapi_incinv_create_tax
with default key.
types:
begin of ty_bapidata,
headerdata type bapi_incinv_create_header,
docnumber type bapi_incinv_fld-inv_doc_no,
fiscalyear type bapi_incinv_fld-fisc_year,
itemdata type ty_tbl_item,
glaccountdata type ty_tbl_gl_account,
taxdata type ty_tbl_tax,
end of ty_bapidata,
ty_tbl_bapidata type standard table of ty_bapidata.
Regards,
Rich Heilman
Message was edited by:
Rich Heilman