Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Get z table data to internal table

Former Member
0 Likes
1,514

hi friends,

when i'm trying to get ztable data to an internal table and run the smartform it's giving a runtime error saying

"In the function module interface, you can specify only fields of a specific type and length under "ITAB".

Although the currently specified field "IT_ZPPR2" is the correct type, its length is incorrect."

here is my se38 code


REPORT  ZPPR_2.

TYPE-POOLS: SLIS.
TABLES : MAST, STPO, ZPPR2.

DATA ITAB LIKE ZPPR2 OCCURS 0 WITH HEADER LINE.

TYPES : BEGIN OF TY_FINAL,

  WERKS TYPE ZPPR2-WERKS, "PLANT
  MATNR TYPE ZPPR2-MATNR, "MATERIAL
  MENGE TYPE ZPPR2-MENGE, "QTY

END OF TY_FINAL.
DATA : IT_ZPPR2 TYPE TABLE OF TY_FINAL WITH HEADER LINE,
       WA_ZPPR2 TYPE TY_FINAL.


START-OF-SELECTION.

SELECT * FROM ZPPR2
  INTO CORRESPONDING FIELDS OF TABLE IT_ZPPR2.

CALL FUNCTION '/1BCDWB/SF00000081'
* EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
  TABLES
    ITAB                       = IT_ZPPR2
* EXCEPTIONS
*   FORMATTING_ERROR           = 1
*   INTERNAL_ERROR             = 2
*   SEND_ERROR                 = 3
*   USER_CANCELED              = 4
*   OTHERS                     = 5
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

5 REPLIES 5
Read only

koolspy_ultimate
Active Contributor
0 Likes
1,201

did you declare the ztable in smartforms? (if it is a driver program)

Read only

0 Likes
1,201

yes, like this

ITAB LIKE ZPPR2

under Tables tab in Form Interface

Read only

0 Likes
1,201

Hi,

In smartform you have declared as below,

yes, like this

ITAB LIKE ZPPR2

under Tables tab in Form Interface

Then why in program,

TYPES : BEGIN OF TY_FINAL,
 
  WERKS TYPE ZPPR2-WERKS, "PLANT
  MATNR TYPE ZPPR2-MATNR, "MATERIAL
  MENGE TYPE ZPPR2-MENGE, "QTY
 
END OF TY_FINAL.
DATA : IT_ZPPR2 TYPE TABLE OF TY_FINAL WITH HEADER LINE,
       WA_ZPPR2 TYPE TY_FINAL.

declare IT_ZPPR2 same in program and smartform both.

declare in program as,

DATA : IT_ZPPR2 type table of ZPPR2 ,
       WA_ZPPR2 TYPE zpr2.

Hope above will solve your problem.

Read only

0 Likes
1,201

Hi,

IT_ZPPR2 TYPE TABLE OF TY_FINAL WITH HEADER LINE,

Although the currently specified field "IT_ZPPR2" is the correct type, its length is incorrect

As the error mentions that the length is incorrect, but the type is correct, try passing IT_ZPPR2[], as you have declared IT_ZPPR with header line without the brackets it would just be the header line that is being passed..

Regards,

Chen

Read only

lijisusan_mathews
Active Contributor
0 Likes
1,201

Hi,

Does the table ZPPR2 have any extra fields other than the 3 in ty_final..( even MANDT )? In that case, this can cause an error.

Also when u pass the internal table to the Smartform you are now passing only the header line. It should be it_ppr2[].

Also to make sure the length is correct, declare it_ppr2 as

data: it_zppr2 type table of zppr2. and ZPPR2 structure can be assigned in the smartform too

Regards,

Suzie

Edited by: Suzie on Jul 1, 2011 10:03 AM