cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Code in transfer and update rules

Former Member
0 Kudos

Hi all,

Can anyone explain me what this code does

loop at DATA_PACKAGE.

Select single /BIC/ZBRODSEG into DATA_PACKAGE-/BIC/ZBRODSEG

From /BIC/MZSEGMENT

Where /BIC/ZSEGMENT = DATA_PACKAGE-/bic/zsegment.

CALL FUNCTION 'ZBW_GET_PRICE_NEW'

EXPORTING

facility = DATA_PACKAGE-/bic/zfacilty

slsmod = DATA_PACKAGE-/bic/zslsmod

date = DATA_PACKAGE-/BIC/ZORDDATE

brodseg = DATA_PACKAGE-/bic/zbrodseg

dealer = DATA_PACKAGE-/bic/zdlrcode

segment= DATA_PACKAGE-/bic/zsegment

IMPORTING

RESULT1= DATA_PACKAGE-/BIC/ZP3

RESULT2= DATA_PACKAGE-/bic/ZP4

EXCEPTIONS

no_price_found = 1

invalid_price_type = 2

dealer_data_not_found = 3

OTHERS = 4.

DATA_PACKAGE-currency = 'USD'.

modify DATA_PACKAGE.

endloop.

I appreciate your help.

thanks,

Sabrina.

View Entire Topic
Former Member
0 Kudos

Hi Sabrina,

This is a code in a start routine in URs.

For each record in a datapackage coming from a communication structure it does the following:

- inserts into datapackage ZBRODSEG field from a view table /BIC/MZSEGMENT where /BIC/ZSEGMENT field of this view = /bic/zsegment field of datapackage.

- then a custom ZBW_GET_PRICE_NEW function with parameters is called.

- results as RESULT1 and RESULT2 are returned by the function and are written into /BIC/ZP3 and /BIC/ZP4 fields of the datapackage. I assume these are prices.

- a currency field of datapackage is modified to 'USD'.

- string of the datapackage is updated.

So, during these code execution four fields in the datapackage are modified: /BIC/ZBRODSEG, /BIC/ZP3, /BIC/ZP4 and currency.

Best regards,

Eugene

Former Member
0 Kudos

Thankyou very much Eugene, You explained it very clearly.

I wanted to give you 10 points but have few more questions, so didn't want to close this. Thanks again.

Sabrina.

Former Member
0 Kudos

Hi Eugene,

Please answer my questions

1. What does Select single do, I know about a select statement, is it that select single gets records one by one from the internal table data_package?

3. How do you know that /BIC/MZSEGMENT is a view.

4. Where can I look for the 'ZBW_GET_PRICE_NEW' function definition.

5. As you said " results as RESULT1 and RESULT2 are returned by the function and are written into /BIC/ZP3 and /BIC/ZP4 fields of the datapackage. I assume these are prices", if that is case then shouldn't it be

DATA_PACKAGE-/BIC/ZP3= result1

DATA_PACKAGE-/bic/ZP4= result2

instead of

RESULT1= DATA_PACKAGE-/BIC/ZP3

RESULT2= DATA_PACKAGE-/bic/ZP4

6. What does the modify data_package statement do

7. will this statement "DATA_PACKAGE-currency = 'USD'" change the currency of the field 'DATA_PACKAGE_currency' to USD.

thanks again

I really appreciate your help.

Sabrina.

Former Member
0 Kudos

Hi Sabrina,

1. 'Select single' will select just one field from each record. In your case - it'll be /BIC/ZBRODSEG. Selecting records one by one from the package is done in

LOOP AT DATA_PACKAGE.

ENDLOOP.

statements.

3. /BIC/MZSEGMENT - is a view because of naming convention - M-table is a view. You can look at this view in SE11 choosing 'View' radio button.

4. For a function you need to go to SE37.

5. Formal parameters of the function are to be at the left side.

In the function call we see definition

IMPORTING

RESULT1= DATA_PACKAGE-/BIC/ZP3

RESULT2= DATA_PACKAGE-/bic/ZP4

It means that the function will EXPORT (the opposite action comparing with function call) calculated results from formal parameters RESULT1 & RESULT2 into actual parameters DATA_PACKAGE-/BIC/ZP3 & DATA_PACKAGE-/BIC/ZP4.

6. MODIFY DATA_PACKAGE will write all the changes in the current record back into the data package.

7. Yes, the currency will be always USD.

Best regards,

Eugene

Former Member
0 Kudos

Hi Eugene, Thanks.

Sabrina.