cancel
Showing results for 
Search instead for 
Did you mean: 

Exit Function not modifying any records

Former Member
0 Kudos

I´m trying to do a unit conversion using an exit function. I´m not able to change the records, it says 1300 records read but 0 modified.

This is the code that I have, does someone know what I´m missing?

FUNCTION Z_BPS_UNIT_CONVERSION_I.

*"----

-


""Interfase local

*" IMPORTING

*" REFERENCE(I_AREA) TYPE UPC_Y_AREA OPTIONAL

*" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL OPTIONAL

*" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA OPTIONAL

*" EXPORTING

*" REFERENCE(ETH_CHAS) TYPE HASHED TABLE

*" CHANGING

*" REFERENCE(XS_CHAS) TYPE ANY OPTIONAL

*"----

-


  • TABLES: ...

TABLES: /BI0/PMAT_UNIT.

  • DATA: ...

DATA: lineref type ref to data,

tab type ref to data,

ls_chasel type UPC_YS_CHASEL,

lt_charng type UPC_YT_CHARNG,

ls_charng type UPC_Ys_CHARNG,

ls_area type UPC_Y_AREA.

  • FIELD-SYMBOLS: ...

field-symbols: type any.

  • TYPES: ...

TYPES:

begin of l_add,

0MATERIAL(1 type c,

0COPASLQTY type p,

ZINVCDQTE type p,

end of l_add.

DATA:

g_s_data TYPE l_add.

  • Create a line that looks like the output table

create data lineref like line of eth_chas.

assign lineref->* to to g_s_data.

  • Create output lines

SELECT SINGLE *

FROM /BI0/PMAT_UNIT

WHERE MATERIAL = g_s_data-0MATERIAL AND

MAT_UNIT = 'EMB'.

g_s_data-ZINVCDQTE = g_s_data-0copaslqty *

/bi0/pmat_unit-DENOMINTR

/ /bi0/pmat_unit-numerator.

move-corresponding g_s_data to into table eth_chas.

ENDLOOP.

Thanks a lot!!!

Theresa.

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member200327
Active Contributor
0 Kudos

T(h)eresa,

The User exit parameters you have in your code sample are from Initialization. So, where is your Z_BPS_UNIT_CONVERSION_I function located: in Function Module box or in FM intialization?

Correct FM returns data in XTH_DATA table, not ETH_CHAS.

Regards,

Gersh

Former Member
0 Kudos

Gersh,

It is located in the function module and not in the initialization, sorry about that I´m completelly new using this kind of functions.

If I move this function to the FM what should I put in the function module since the field is mandatory?

I´m just trying to modify the value of one KF.

Best Regards,

Teresa.

former_member200327
Active Contributor
0 Kudos

Teresa,

Location of the Function name is correct for your purposes. You just have to change list of parameters for this function. You can find the correct list in the Help of that field.

Please let me now if you need additional information.

Regards,

Gersh

Former Member
0 Kudos

Gersh,

After what you told me I left the function in the function module box and not in the intialization.

I made the changes to point to the table that you mentioned but the records are still the same.

FUNCTION Z_BPS_UNIT_CONVERSION_I.

*"----


""Interfase local

*" IMPORTING

*" REFERENCE(I_AREA) TYPE UPC_Y_AREA OPTIONAL

*" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL OPTIONAL

*" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA OPTIONAL

*" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL OPTIONAL

*" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD OPTIONAL

*" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM OPTIONAL

*" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE OPTIONAL

*" EXPORTING

*" REFERENCE(XTH_DATA) TYPE HASHED TABLE

*"----


  • TABLES: ...

TABLES: /BI0/PMAT_UNIT.

  • DATA: ...

DATA: lineref type ref to data,

tab type ref to data,

ls_chasel type UPC_YS_CHASEL,

lt_charng type UPC_YT_CHARNG,

ls_charng type UPC_Ys_CHARNG,

ls_area type UPC_Y_AREA.

  • FIELD-SYMBOLS: ...

field-symbols: <fs> type any.

  • TYPES: ...

TYPES:

begin of l_add,

0MATERIAL(18) type c,

0COPASLQTY type p,

ZINVCDQTE type p,

end of l_add.

DATA:

g_s_data TYPE l_add.

CALL FUNCTION 'Z_BPS_UNIT_CONVERSION_I'

EXPORTING

I_AREA = 'ZATEST01'

IMPORTING

XTH_DATA = <fs>.

  • Create a line that looks like the output table

create data lineref like line of XTH_DATA.

assign lineref->* to <fs>.

LOOP AT XTH_DATA ASSIGNING <fs>.

move-corresponding <fs> to g_s_data.

  • Create output lines

SELECT SINGLE *

FROM /BI0/PMAT_UNIT

WHERE MATERIAL = g_s_data-0MATERIAL AND

MAT_UNIT = 'EMB'.

if sy-subrc = 0.

g_s_data-ZINVCDQTE = g_s_data-0copaslqty *

( /bi0/pmat_unit-DENOMINTR / /bi0/pmat_unit-numerator ).

endif.

move-corresponding g_s_data to <fs>.

modify table XTH_DATA from <fs>.

ENDLOOP.

ENDFUNCTION.

Any ideas?

Thanks a lot for your help!!!

Theresa.

Former Member
0 Kudos

Gersh,

I tried also this way using UPF_PRICE as a model but the records are still not being modified.

FUNCTION Z_BPS_UNIT_CONVERSION_I.

*"----


""Interfase local

*" IMPORTING

*" REFERENCE(I_AREA) TYPE UPC_Y_AREA OPTIONAL

*" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL OPTIONAL

*" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA OPTIONAL

*" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL OPTIONAL

*" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD OPTIONAL

*" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM OPTIONAL

*" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE OPTIONAL

*" EXPORTING

*" REFERENCE(ET_MESG) TYPE UPC_YT_MESG

*" CHANGING

*" REFERENCE(XTH_DATA) TYPE HASHED TABLE

*"----


  • TABLES: ...

TABLES: /BI0/PMAT_UNIT.

  • DATA: ...

DATA: lineref type ref to data,

tab type ref to data,

ls_chasel type UPC_YS_CHASEL,

lt_charng type UPC_YT_CHARNG,

ls_charng type UPC_Ys_CHARNG,

ls_area type UPC_Y_AREA.

*ls_area = 'ZATEST01'.

  • FIELD-SYMBOLS: ...

field-symbols: <fs> type any.

  • TYPES: ...

TYPES:

begin of l_add,

0MATERIAL(18) type c,

0COPASLQTY type p,

ZINVCDQTE type p,

end of l_add.

DATA:

g_s_data TYPE l_add.

  • CALL FUNCTION 'Z_BPS_UNIT_CONVERSION_I'

  • EXPORTING

  • I_AREA = 'ZATEST01'

  • IMPORTING

  • XTH_DATA = <fs>.

  • Create a line that looks like the output table

create data lineref like line of XTH_DATA.

assign lineref->* to <fs>.

LOOP AT XTH_DATA ASSIGNING <fs>.

move-corresponding <fs> to g_s_data.

  • Create output lines

SELECT SINGLE *

FROM /BI0/PMAT_UNIT

WHERE MATERIAL = g_s_data-0MATERIAL AND

MAT_UNIT = 'EMB'.

if sy-subrc = 0.

g_s_data-ZINVCDQTE = g_s_data-0copaslqty *

( /bi0/pmat_unit-DENOMINTR / /bi0/pmat_unit-numerator ).

endif.

move-corresponding g_s_data to <fs>.

modify table XTH_DATA from <fs>.

ENDLOOP.

ENDFUNCTION.

former_member200327
Active Contributor
0 Kudos

Teresa,

Now the function looks much better. But there is still something wrong with your first code sample: you have a recursive Function call of Z_BPS_UNIT_CONVERSION_I. It shouldn't be there.

Also you don't need MODIFY or INSERT: you are working directly in the table because you use LOOP ... ASSIGNING... . I.e., as soon as you change the field in <fs> it's changed in the table. Just don't move the record to g_s_data and back.

I'd consider putting a break-point in this FM to see if it's being called. Debugging will also make the picture clearer for you.

Please let me know if this helped.

Regards,

Gersh

Former Member
0 Kudos

Gersh,

Instead of using MODIFY FROM I used COLLECT and the KF was modified.

The only problem is that instead of modifing the right KF it modifies always the original one.

The KF 0copaslqty is the one that is being modified instead of ZINVCDQTE and ZNET is not getting any value.

g_s_data-ZINVCDQTE = g_s_data-0copaslqty *

/bi0/pmat_unit-DENOMINTR

/ /bi0/pmat_unit-numerator.

g_s_data-ZNET = g_s_data-0copaslqty.

endif.

move-corresponding g_s_data to <fs>.

  • modify table XTH_DATA from <fs>.

collect <fs> into xth_data.

Regards,

Theresa.

former_member200327
Active Contributor
0 Kudos

It's nice to see that you made some progress:).

When you do COLLECT it modifies ALL numerical fields of g_s_data. Can you see what do you have in 0copaslqty before you collect? If you want to keep the old value this field in g_s_data should be zero.

Also, can you see in debug mode what values are in ZINVCDQTE and ZNET in g_s_data?

Regards,

Gersh

Former Member
0 Kudos

Gersh,

It´s nice I made some progress... even though is not doing what I want.

i´m able to see the value for 0COPASLQTY, what do you mean by "...If you want to keep the old value this field in g_s_data should be zero". Do I need to initialize all KFs that I want to keep the value with zero?

Also I don´t understand why ZINVCDQTE and ZNET are not getting the new value. They stay with the same value that the have at the moment.

Best Regards,

Theresa.

former_member200327
Active Contributor
0 Kudos

Theresa,

First you move corresponding from <fs> to g_s_data. I'd assume this populates 0COPASLQTY as well. Than you COLLECT and this should double 0COPASLQTY. That's what I meant when I said that you have to CLEAR 0COPASLQTY before COLLECTing it.

Have you been able to put a BREAK-POINT in this FM to see values in ZINVCDQTE and ZNET?

Regards,

Gersh

former_member200327
Active Contributor
0 Kudos

Hi Theresa,

The main purpose of this User Exit is to modify key figures, not Characteristics. Hence you can use MODIFY if you want to change a KF value. Also characteristics are keys of the HASH table and therefore can't be changed.

So, if you want to change a Characteristics, you have to delete the old records and insert a new one with a proper combination of characteristics.

Please let me know if you need more details.

Regards,

Gersh

Former Member
0 Kudos

Gersh,

I see only a qty field as modified field in this code...am I wronging?

Bye,

Roberto

former_member200327
Active Contributor
0 Kudos

Roberto,

I didn't look at the code, I looked at the description: Unit Of Measure is a characteristic and this User exit is for Initialization:(

Might be this is the reason:)

Gersh

Former Member
0 Kudos

I´m only trying to modify a KF not a characteristic.

Do I need to create an initialization function?

I´m doing an xecution with trace and I´m able to see the data but the records are not being modified.

Former Member
0 Kudos

Sergio

The problem is that you inserting into eth_chas. You should be modifying the record.

This should solve your problem.

Jita

Former Member
0 Kudos

Hi Theresa,

I think you have to do a MODIFY FROM and not an INSERT in the end of your code !

Hope it helps!

Bye,

Roberto

Former Member
0 Kudos

I did the modify statement but still doesn´t work.

modify table eth_chas from .

Any other ideas?

Thanks a lot.

Theresa.

Former Member
0 Kudos

Try to put this one:

if sy-subrc = 0

g_s_data-0copaslqty * ( /bi0/pmat_unit-DENOMINTR / /bi0/pmat_unit-numerator )

else.

  • manage here the situation in which you don't have conversion to do

endif.

Former Member
0 Kudos

Roberto,

I tried what you told me but it doesn´t work.

Any ideas?

Thanks a lot!!!

Teresa.