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

How to use import/Export to/from Database statement

Former Member
0 Likes
2,593

Hi Expert,

My requirement is to  perform some validations during GR and to display error messages based on validations. I have performed  some checks in PAI_HEADER method of BADI mb_migo_badi, and based on these checks I have tried to display error message through Check_header method of BADI mb_migo_badi.

To achieve this I have exported a parameter from the method PAI_HEADER and Imported it in Check_header method, But I did not get any value in the import parameter of check_header.

The lines of sample code I wrote for this is:

In PAI_HEADER method-


Data: ET_BAPIret2_1 type table of  BAPIRET2,

        wa_bapiret like line of et_bapiret2_1.

  Data: ET_BAPIret2 type table of  BAPIRET2.

wa_bapiret-type = 'E'.

       wA_bapiret-ID = 'ZSCM'.

       wA_bapiret-NUMBER = '018'.

       append wa_bapiret to et_bapiret2_1.

     Export et_bapiret2_1 FROM et_bapiret2 to DATABASE demo_indx_table(hk) ID 'HK'

In Check_header Method-

  Data: ET_BAPIret2_1 like ET_BAPIRET2.

 

  import ET_Bapiret2 to ET_BAPIret2_1 from database demo_indx_table(hk) ID 'HK'.

I have checked this code in debugging mode, the table et_bapiret2_1 has values in Method PAI_HEADER  while the table is initial in CHECK_HEADER Method.

Guys Can you please tell me if I am doing something wrong here.

Thanks in advance.

Regards,

Arshad

Hi Expert,

My requirement is to  perform some validations during GR and to display error messages based on validations. I have performed  some checks in PAI_HEADER method of BADI mb_migo_badi, and based on these checks I have tried to display error message through Check_header method of BADI mb_migo_badi.

To achieve this I have exported a parameter from the method PAI_HEADER and Imported it in Check_header method, But I did not get any value in the import parameter of check_header.

The lines of sample code I wrote for this is:

In PAI_HEADER method-


Data: ET_BAPIret2_1 type table of  BAPIRET2,

        wa_bapiret like line of et_bapiret2_1.

  Data: ET_BAPIret2 type table of  BAPIRET2.

wa_bapiret-type = 'E'.

       wA_bapiret-ID = 'ZSCM'.

       wA_bapiret-NUMBER = '018'.

       append wa_bapiret to et_bapiret2_1.

     Export et_bapiret2_1 FROM et_bapiret2 to DATABASE demo_indx_table(hk) ID 'HK'

In Check_header Method-

  Data: ET_BAPIret2_1 like ET_BAPIRET2.

 

  import ET_Bapiret2 to ET_BAPIret2_1 from database demo_indx_table(hk) ID 'HK'.

I have checked this code in debugging mode, the table et_bapiret2_1 has values in Method PAI_HEADER  while the table is initial in CHECK_HEADER Method.

Guys Can you please tell me if I am doing something wrong here.

Thanks in advance.

Regards,

Arshad

3 REPLIES 3
Read only

custodio_deoliveira
Active Contributor
0 Likes
2,127

Hi Arshad,

You should import exactly what you exported:

   import ET_Bapiret_2 to ET_BAPIret2_1 from database demo_indx_table(hk) ID 'HK'.

Cheers,

Custodio

Read only

arindam_m
Active Contributor
0 Likes
2,126

Hi,

I think the context might be a issue choose the SHARED BUFFER thing so that it is in the SHARED context. Also check then link below. Have you defined the DB table (demo_indx_table) ? As, the context is OO you might need to do this as an Attribute to visible in scope all along.

http://help.sap.com/saphelp_40b/helpdata/EN/34/8e73a36df74873e10000009b38f9b8/content.htm

Cheers,

Arindam

Read only

Former Member
0 Likes
2,126

You have not given the correct names in the export and import statement

Data: ET_BAPIret2_1 type table of  BAPIRET2,

        wa_bapiret like line of et_bapiret2_1.

  Data: ET_BAPIret2 type table of  BAPIRET2.

wa_bapiret-type = 'E'.

       wA_bapiret-ID = 'ZSCM'.

       wA_bapiret-NUMBER = '018'.

       append wa_bapiret to et_bapiret2_1.

     Export et_bapiret2_1 to DATABASE demo_indx_table(hk) ID 'HK'

In Check_header Method-

  Data: ET_BAPIret2_1 type table of  BAPIRET2. like ET_BAPIRET2.

 

  import et_bapiret2_1 from database demo_indx_table(hk) ID 'HK'.

Also make sure that you have given the table declaration statement.

TABLES demo_indx_table.