Skip to Content

Exit Functions

Hi,

I am new to exit functions so please bare with me.

I am calling an exit function to take the price from one table and use this value to multiply by the quantity field and to update the total value in another table (both quantity and total in the one table). Both tables are in the planning function and are read by the exit function.

The first time the function is called it gets the price (only one price line) from the table. The second time the function is called, it goes through the quantities fields and updates the total.

My problem is that I loose the value of the price when the function is called the second time. How do i keep this value.

Here is my attempt:

FUNCTION ZPF_MODIFY_KEY_FIGURE.

*"----


""Local interface:

*" IMPORTING

*" REFERENCE(I_AREA) TYPE UPC_Y_AREA

*" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL

*" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD

*" REFERENCE(I_PARAM) TYPE UPC_Y_PARAM

*" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE

*" REFERENCE(IT_EXITP) TYPE UPF_YT_EXITP

*" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL

*" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA

*" REFERENCE(ITO_KYF) TYPE UPC_YTO_KYF

*" EXPORTING

*" REFERENCE(ET_MESG) TYPE UPC_YT_MESG

*" CHANGING

*" REFERENCE(XTH_DATA) TYPE HASHED TABLE

*"----


DATA: ls_exitp TYPE upf_ys_exitp.

DATA: ls_mesg TYPE upc_ys_mesg.

DATA: G_PRICE TYPE F.

DATA: COUNT TYPE F.

FIELD-SYMBOLS: <ls_data> TYPE ANY.

BREAK-POINT.

COUNT = 0.

LOOP AT xth_data ASSIGNING <ls_data>.

IF COUNT = 0.

PERFORM GET_PRICE1 USING <ls_data>

CHANGING G_Price.

COUNT = 1.

ELSE.

PERFORM modify_param_value USING G_PRICE

CHANGING <ls_data>

et_mesg.

ENDIF.

ENDLOOP.

ENDFUNCTION.

************************************************************************

----


  • FORM modify_param_value *

----


FORM modify_param_value USING G_PRICE TYPE ANY

CHANGING xs_data TYPE any

lt_mesg TYPE upc_yt_mesg.

FIELD-SYMBOLS: <weight> type ANY,

<value> type any,

<struct> TYPE ANY.

  • choose second structure which contains the keyfigures

ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE xs_data TO <struct>.

ASSIGN COMPONENT '0G_QVV900' OF STRUCTURE <struct> TO <weight>.

ASSIGN COMPONENT 'ZOFF_TOT' OF STRUCTURE <struct> TO <value>.

<value> = <weight> * G_PRICE.

ENDFORM. "modify_param_value

************************************************************************

&----


*& Form get_price

&----


FORM GET_PRICE1 USING xs_data type any

changing G_PRICE type any.

FIELD-SYMBOLS: <price> type ANY,

<struct> TYPE ANY.

ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE xs_data TO <struct>.

ASSIGN COMPONENT 'ZOFFPERC' OF STRUCTURE <struct> TO <price>.

G_PRICE = <price>.

ENDFORM. "get_price

Any help would be much appreciated

Thanks,

Finbarr

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 19, 2005 at 12:29 AM

    Hello Finbarr,

    You can stop G_PRICE from being erased one of two ways

    1/ You can go ahead and declare this variable

    > DATA: G_PRICE TYPE F.

    within the function group that contains your exit function ZPF_MODIFY_KEY_FIGURE so that when you set it with the first call to your exit function module it will remain in memory when it is called a second time.

    2/ The second way you can do this although not as simple as the first is to export it to ABAP memory and then re-import it each additional time that the function module is called for example.

    DATA: ls_exitp TYPE upf_ys_exitp,

    ls_mesg TYPE upc_ys_mesg,

    G_PRICE TYPE F,

    COUNT TYPE F.

    import g_price from memory id 'g_price'.

    if sy-subrc ne 0.

    PERFORM GET_PRICE1 USING <ls_data>

    CHANGING G_Price.

    export g_price to memory id 'g_price'.

    else.

    PERFORM modify_param_value USING G_PRICE

    CHANGING <ls_data>

    et_mesg.

    ENDIF.

    You'll have to double check the syntax. I recommend trying the first option, it is a lot easier, just move your data declaration to the global variable portion of your function group.

    Hope this helps.

    Cheers,

    Scott

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 19, 2005 at 09:51 AM

    Scott,

    I used the first step you told me and it worked fine.

    Thanks for your help.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.