on 06-04-2005 12:12 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
Hi,
SELECT SINGLE : doesn't mean that it will select single field from the record..
1) let us suppose you have to find out a particular record with particular selection..In your case you need to findout /BIC/ZBRODSEG for the value DATA_PACKAGE-/bic/zsegment..
Then It will select single record from the data...but you need to pass full primary key in this case..see view /BIC/MZSEGMENT ,there must be /BIC/ZSEGMENT the single primary key...
If it doesn't contain single primary key..I mean if it is composit then you need to use the syntax..SELECT --- UP TO N ROWS.....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sabrina,
SELECT SINGLE will return a single line. If SELECT can return more than one line from the database, the first line that is found is entered into the resulting set.
You can also get not only one field with SELECT SINGLE but also several ones (from a single record).
For example,
SELECT SINGLE a b FROM <table> INTO (x, y)
WHERE ...
will return two fields.
Best regards,
Eugene
sabrina,
Please give us the scenario , and also if you have any problems with the current routine - it would help. and as eugene pointed out - it is in the start routine and not transfer rules or update rules.
Arun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.