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

Getting Customer number from customer master program(XD01) to custom subscreen program.

Former Member
0 Likes
2,049

Hi All,

I have created a subscreen in the transactions XD01-03 using BADI CUSTOMER_ADD_DATA_CS. In the method get_taxi_screen i have given the custom program name and the subscreen number i have created.

Problem: I want to get the customer number of the main program in the subscreen program. Based on that customer number i process the data in the subscreen program.

Please share the information if you know how to do it.

Thanks & regards,

NarsiReddy.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,797

In CUSTOMER_ADD_DATA_CS implementation, use method IF_EX_CUSTOMER_ADD_DATA_CS~SET_DATA to pass data from main transaction program to your implementation, and GET_DATA to send changed data back.

Hint: Easiest solution is to create a function group to contain the customer subscreen, and 2 FM to be called from mentioned method and save/read data in global area of FM. If you didn't use a function group but a module pool, you could try to export/import those data into/from memory during your PBO/PAI logic.

Remarks

  • First method SET_DATA will be executed before PBO AND PAI of your customer screen, so protect your changed data from overlapping. (e.g. manage two area in top include TABLES: KNA1, ZAKNA1.)
  • You may also be required to implement BAdI CUSTOMER_ADD_DATA: e.g. methods CHECK_ALL_DATA (case user doesn't display customer screen), SAVE_DATA (case some data is not appended to standard tables but in a customer table) etc.

Regards,

Raymond

Hi All,

I have created a subscreen in the transactions XD01-03 using BADI CUSTOMER_ADD_DATA_CS. In the method get_taxi_screen i have given the custom program name and the subscreen number i have created.

Problem: I want to get the customer number of the main program in the subscreen program. Based on that customer number i process the data in the subscreen program.

Please share the information if you know how to do it.

Thanks & regards,

NarsiReddy.

10 REPLIES 10
Read only

oliver_wurm
Active Participant
0 Likes
1,797

Hi,

you Need to implement method SET_DATA in the same BADI. This method gets all data used in Transaction XD0x so you can write the Information to global fields in your custom program.

Regards

Oliver

Read only

0 Likes
1,797

Hi Oliver,

Thanks for the quick reply.

Can you please explain it a bit more, for example i create a global field  gv_kunnr in the top include of the custom subscreen program.

How to set the data from set_data method to the global variable.

Thanks in advance,

regards,

NarsiReddy.,

Read only

0 Likes
1,797

Hi,

you can create a FORM in your custom program which you call out of the SET_DATA Method. You pass everything you need to that FORM and the FORM populates the global data fields declared in your TOP include.

Regards

Oliver

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,798

In CUSTOMER_ADD_DATA_CS implementation, use method IF_EX_CUSTOMER_ADD_DATA_CS~SET_DATA to pass data from main transaction program to your implementation, and GET_DATA to send changed data back.

Hint: Easiest solution is to create a function group to contain the customer subscreen, and 2 FM to be called from mentioned method and save/read data in global area of FM. If you didn't use a function group but a module pool, you could try to export/import those data into/from memory during your PBO/PAI logic.

Remarks

  • First method SET_DATA will be executed before PBO AND PAI of your customer screen, so protect your changed data from overlapping. (e.g. manage two area in top include TABLES: KNA1, ZAKNA1.)
  • You may also be required to implement BAdI CUSTOMER_ADD_DATA: e.g. methods CHECK_ALL_DATA (case user doesn't display customer screen), SAVE_DATA (case some data is not appended to standard tables but in a customer table) etc.

Regards,

Raymond

Read only

0 Likes
1,797

Hi Raymond,

I am using Module pool. I am not changing any data of the database tables and i don't write any data to them as well. I just need to know the customer number. Using this customer number, i will make changes to my custom table in the PBO of my subscreen.

Depending on the customer number, i will display an alv table(custom table) and if user makes any changes to it, i will just update my custom table.

So in the IF_EX_CUSTOMER_ADD_DATA_CS~SET_DATA i exported like below.

    


EXPORT s_kna1-kunnr FROM s_kna1 TO MEMORY id  'ADD_CUS_123'.

In the PBO of the subscreen i have imported as below:


IMPORT s_kna1-kunnr TO gv_kunnr FROM MEMORY ID 'ADD_CUS_123'.

gv_kunnr is a global variable of type kunnr, i declared in the top include. I am getting short dump when executing this Import.

Do i need to export and import the whole table?

Thanks & regards,

NarsiReddy.

Read only

0 Likes
1,797

Hi Raymond,

its working fine now.

In IF_EX_CUSTOMER_ADD_DATA_CS~SET_DATA  i have exported the customer number.


     DATA: gv_kunnr TYPE kna1-kunnr.

     gv_kunnr = s_kna1-kunnr.

EXPORT gv_kunnr FROM gv_kunnr TO MEMORY id  'ADD_CUS_123'.

and in the PBO of the subscreen i have imported the customer number.


IMPORT gv_kunnr to gv_kunnr FROM MEMORY ID 'ADD_CUS_123'.

gv_kunnr is declared of type kna1-kunnr in the top include.

Thank you.

regards,

NarsiReddy.

Read only

0 Likes
1,797

Well today you only require the customer number, but can you sure, you won't need more information in the future?

Also, i didn't think on an alternative to EXPORT/IMPORT, you could execute a FORM of your module pool in the method.


PERFORM myform IN PROGRAM sapmzmyprog USING kna1-kunnr.

Regards,

Raymond

Read only

nishantbansal91
Active Contributor
0 Likes
1,797

Hi,

If you can check the parameter ID you will find the same. KUN is the parameter id.

Thanks

Nishant

Read only

0 Likes
1,797

Hi Nishant,

How to do in this way?

setting parameter id? what do we need to do in the IF_EX_CUSTOMER_ADD_DATA_CS~SET_DATA and in the PBO of our subscreen.

Thanks & regards,

NarsiReddy.

Read only

0 Likes
1,797

I suppose Nishant suggested that a


GET PARAMETER ID 'KUN' FIELD wa_kunnr.

could fulfill the current requirement, but what would happen if user execute same transaction on 2 distinct modes of the same session.

Regards,

Raymond