Application Development 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: 

Data incompatibility when passing a deep structure

ramiwal_dsilva
Participant
0 Kudos

Hello Experts,

I am facing an issue

I'm trying to pass xvbak from a standard program  to a class method

the formal parameters are defined as

DATA: BEGIN OF xvbak.             
              INCLUDE STRUCTURE vbak.
DATA:       bstkd                LIKE vbkd-bstkd.
DATA:       kursk                LIKE vbkd-kursk.         
DATA:       zterm               LIKE vbkd-zterm.        
DATA:       inco1                LIKE vbkd-inco1.

DATA: END OF xvbak.



When i try to pass XVBAK to my class method i get a data incompatibility error  between CS_XVBAK and XVBAK. although both are types to the same set of fields.


CALL METHOD Object->DETERMINE_customer 

     Changing

               CS_XVBAK  = XVBAK




This is how CS_XVBAK (Actual Parameters) have been typed inside my class as a changing Parameter.


types:

     BEGIN OF GTY_XVBAK,
            p_vbak type vbak,

            bstkd TYPE vbkd-bstkd,
            kursk TYPE vbkd-kursk,         
            zterm TYPE vbkd-zterm,        l
            inco1 TYPE vbkd-inco1, 

     END OF GTY_XVBAK .      
               

Changing Parameter: 

Data: CS_XVBAK type GTY_XVBAK.


Is there an issue with the above code?... Im just wondering if the include structure in both declarations is the cause of the issue?

Is there a correct way of making 2 deep structures compatible?


Any help will be highly appreciated.


    

1 ACCEPTED SOLUTION

Private_Member_14913
Contributor
0 Kudos

Hello,

Structure CS_XVBAK is declared as complex structure, so it is Include of VBAK. See below screen-shot.

While XVBAK structure is simple structure with all fields are at same level. see below screen-shot.

You need to declare as below.

types: wa_vbak TYPE vbak.

types:

      BEGIN OF GTY_XVBAK.

             INCLUDE type wa_vbak.

types:       bstkd TYPE vbkd-bstkd,

             kursk TYPE vbkd-kursk,

             zterm TYPE vbkd-zterm,

             inco1 TYPE vbkd-inco1,

      END OF GTY_XVBAK .




Regards,

Sameer

6 REPLIES 6

Private_Member_14913
Contributor
0 Kudos

Hello,

Structure CS_XVBAK is declared as complex structure, so it is Include of VBAK. See below screen-shot.

While XVBAK structure is simple structure with all fields are at same level. see below screen-shot.

You need to declare as below.

types: wa_vbak TYPE vbak.

types:

      BEGIN OF GTY_XVBAK.

             INCLUDE type wa_vbak.

types:       bstkd TYPE vbkd-bstkd,

             kursk TYPE vbkd-kursk,

             zterm TYPE vbkd-zterm,

             inco1 TYPE vbkd-inco1,

      END OF GTY_XVBAK .




Regards,

Sameer

0 Kudos

Thanks Sameer for the detailed analysis and prompt reply, i managed to include a type vbak inside a type just as you mentioned, but it still doesnt seem to work .. ...

0 Kudos

Hello,

What kind of error it is giving?

Alternatively, try to declare structure in data dictionary(T-code: SE11) used in your program & class, so that definition will be same at both places.

Regards,

Sameer

0 Kudos

Hello,

I tried to declare type in dummy class ZZTEST & call same structure mention above.

It is working at my end, see below screen-shot.

Regards,

Sameer

ronaldo_aparecido
Contributor
0 Kudos

Hi Ramiwal.

The error ocurred because the declaration of GTY_XVBAK IS WRONG.

     BEGIN OF GTY_XVBAK,
            p_vbak type
vbak,


The correct is :

     BEGIN OF GTY_XVBAK,

    include structure INCLUDE STRUCTURE vbak.



Hope helped you.

ramiwal_dsilva
Participant
0 Kudos

Thanks sameer!!!!...it works now... i actually missed one parameter , so it threw up a few errors.... its fine now... thanks so much for your help