on 07-24-2023 6:10 PM
Hello,
My task is to calculate the value for revenue, like revenue = hourrate * hour.
i get the hour from my Result_package and the hourrate from my active database table that i read into my program.
This is my code so far. The problem with this code is, that the field <fs_line>-/bic/mihstsas has always the value of the last iteration of the second loop. for example the last loop has the role 'Senior' and therfore the hourrate 100€. the programm will then correctly calculate the value for revenue in my result_package. the problem is that when the first loop gets to a record where the Role is 'Junior' the programm will still have the hourrate of 100, wich is wrong. How can i write the code so that the programm will get the correct Hourrate for the corresponding role.
result package
Customer, Role, Hour
lt_Stundensatz
Customer, Roler, Hour rate
calculate revenue (Hour * Hourrate) when Customer and Role are equal
DATA : lt_Stundensatz TYPE TABLE of /BIC/AMIHDSATZ7,
ls_Stundensatz LIKE LINE OF lt_Stundensatz.
FIELD-SYMBOLS : <fs_line> type /BIC/AMIHDSATZ7.
SELECT *
FROM /BIC/AMIHDSATZ7 INTO TABLE lt_Stundensatz.
LOOP AT Result_package ASSIGNING <result_fields>.
LOOP AT lt_Stundensatz ASSIGNING <fs_line>.
READ TABLE lt_Stundensatz into <fs_line> WITH KEY /BIC/mihrolle = <fs_line>-/bic/mihrolle /BIC/mihprkun = <fs_line>-/bic/mihprkun.
ENDLOOP.
if sy-subrc = 0.
<result_fields>-/bic/mihumsatz = <result_fields>-/bic/mihprstu * <fs_line>-/bic/mihstusa.
ENDIF.
ENDLOOP.
Hello Michel,
if I understand your coding correctly, you can work with one Loop only, as well.
I would use the following coding. Give it a try.
TYPE: gs_Stundensatz LIKE LINE OF lt_Stundensatz.
LOOP AT Result_package ASSIGNING <result_fields>.
CLEAR gs_Stundensatz
READ TABLE lt_Stundensatz WITH KEY
/BIC/mihrolle = <fs_line>-/bic/mihrolle
/BIC/mihprkun = <fs_line>-/bic/mihprkun
INTO gs_Stundensatz.
IF sy-subrc = 0.
<result_fields>-/bic/mihumsatz = <result_fields>-/bic/mihprstu * gs_Stundensatz-/bic/mihstusa.
ENDIF.
ENDLOOP.
Best regards, Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
8 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.