11-16-2005 11:16 AM
Hi,
what I'm trying to do is create a screen within a function. What I would like to do is display a number of lines from an internal table, and have ICONS, which I can decide what happens when the user selects an icon ( Pf-status)
What I have done is the following so far, but it will not compile
FUNCTION z_fs_spool_history.
*"----
""Local interface:
*" IMPORTING
*" VALUE(ID_LIST) TYPE SP01R_ID_LIST
*"----
TABLES tsp02.
CALL SCREEN '100'.
Dialog Module PBO
MODULE status_0100 OUTPUT.
ENDMODULE. "STATUS_0100 OUTPUT
Dialog Module PAI
*MODULE user_command_0100 INPUT.
*ENDMODULE. "USER_COMMAND_0100 INPUT
ENDFUNCTION.
Am I approaching this the right way? Or is there a better way of doing this?
11-16-2005 11:22 AM
HI Sims,
Your approach looks OK to me.
Make sure that when you are designing your screen '0100', Call the Module status_0100 in PBO
and module user_command_0100 in PAI sections of the screen.
I suggest to use the se51 transaction to design the screen . Take this advice only if you are not using it right now.
Regards,
Ravi
11-16-2005 11:30 AM
Hi,
why don't I see anything on the screen when I run this then?
FUNCTION z_fs_spool_history.
*"----
""Local interface:
*" IMPORTING
*" VALUE(ID_LIST) TYPE SP01R_ID_LIST
*"----
TABLES tsp02.
CALL SCREEN '100'.
ENDFUNCTION.
Dialog Module PBO
MODULE status_0100 OUTPUT.
SELECT * FROM tsp02.
WRITE tsp02-pjident.
ENDSELECT.
ENDMODULE. "STATUS_0100 OUTPUT
Dialog Module PAI
MODULE user_command_0100 INPUT.
ENDMODULE. "USE
11-16-2005 11:39 AM
HI Sims,
I think while creating the program you have made it a Function pool program.
Instead, it should be a module pool program/ Report program.
And moreover, you cannot run a module pool program just as you run a normal report.
The best way is to assign a transaction code in SE93 Transaction.
and then type your t-code in the T-CODE box(TOP-LEFT corner of the screen).
Also, you must design the screens to enter the data and to display the data.Goto se51 transaction).
Regards,
Ravi
11-16-2005 11:49 AM
Hi,
it needs to be a function.
It is going to be called from a program.
What I am trying to do is list all the spool history from TSP02, with a checkbox next to it, and then allow the user to select certain spools to view and perform various functions. The problem I have is, I have never created a function with a screen before, and am not sure if I should be or not, or just use a classical list.
The following seems to work, but the pf-status does not appeat to display, even though I have gone into it and put in 'BACK' , 'CANCEL' and 'EXIT'.
Any ideas?
11-16-2005 12:04 PM
just check the standard FM
POPUP_TO_DECIDE_INFO
on how you can call screen within function module .
Regards
Raja
11-16-2005 12:05 PM
Hi Sims,
Do you have the
SET PF-STATUS <YOUR PF STATUS>.
statement in your STATUS_0100 module?
And if you have it, is the PF-STATUS already active?
Regards,
Ravi
11-16-2005 12:54 PM
Hi,
what have is the basic function below
FUNCTION z_fs_spool_history.
*"----
""Local interface:
*" IMPORTING
*" VALUE(ID_LIST) TYPE SP01R_ID_LIST
*"----
TABLES tsp02.
CALL SCREEN '100'.
SELECT * FROM tsp02.
WRITE: / tsp02-pjident.
ENDSELECT.
ENDFUNCTION.
I have defined screen 100, and in the flow logic of the screen I have
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
and in the mdoules I have :
----
***INCLUDE LZ_FS_INBOUNDO01 .
----
*{ INSERT R3IK900078 1
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module STATUS_0100 output.
SET PF-STATUS 'MYLIST'.
SET TITLEBAR 'Spool History'.
endmodule. " STATUS_0100 OUTPUT
*} INSERT
I have defined 'MYLIST' and gone in and in the functions keys standard toolbar, put 'BACK' above the icon.
But when I call the function from a program , or test it, the BACK button is still greyed out.
I did set a break point to see if the pf status was being set, and it does appear it is.
11-16-2005 1:00 PM
11-16-2005 1:15 PM
11-16-2005 1:16 PM
Don't know what you mean? It is greyed out , so I don't get to a stage where I can do anything with it
11-16-2005 1:17 PM
The PF-status is active, I activated the whole function group to make sure as well
11-16-2005 1:28 PM
Sims,
I am able to see the PF Status and the BACK button and it is working. But i am unable to see the Data..
Thanks,
Kam
11-16-2005 1:40 PM
Hi Kam,
I've managed to work out why it did not work before.
You have re-activate everything, even though it appears to be active. Huh?*?!
Thanks Anyway
11-16-2005 1:50 PM
Sims,
May be due to some inconsistency!!!
Only SAP knows the Answer.
Please close the threads by awarding points.
Thanks
Kam
11-16-2005 6:17 PM
WRITE statement will not work in screens. It is for list processing. You will either have to have some text fields on the screen or may be a table control for your purpose.
Srinivas
11-16-2005 11:23 AM
Hi Sims,
are you sure that importing parameter ID_LIST is visible from inside the modules?
Try to declare a global variable GLOBAL_ID_LIST in a top include. And set it like this:
GLOBAL_ID_LIST = ID_LIST.
The function seems to be right. (call modules from inside the dynpro).
Maybe it could be better to include forms, modules etc... inside some includes:
For example:
INCLUDE Z_..._TOP for global declarations
INCLUDE Z_..._PBO for PBO modules etc...
Regards, Manuel
11-16-2005 11:24 AM
If you have the data in an internal table why are you creating a Z FM to popup and siplay where we already have an in built FM EUSE_ALV_POPUP_TO_SELECT' way to do that.
Just run the following code.
plz reward points if it helps you.
REPORT BALV_POPUP_TO_SELECT.
TYPE-POOLS: SLIS.
DATA: GT_OUTTAB TYPE SFLIGHT OCCURS 0,
GS_PRIVATE TYPE SLIS_DATA_CALLER_EXIT,
GS_SELFIELD TYPE SLIS_SELFIELD,
gt_fieldcat type slis_t_FIELDCAT_ALV with header line,
G_EXIT(1) TYPE C.
PARAMETERS: P_TITLE TYPE SY-TITLE.
*
START-OF-SELECTION.
SELECT * FROM SFLIGHT INTO TABLE GT_OUTTAB UP TO 5 ROWS.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
changing
ct_fieldcat = gt_fieldcat[].
read table gt_fieldcat with key fieldname = 'PLANETYPE'.
if sy-subrc = 0.
gt_fieldcat-no_out = 'X'.
modify gt_fieldcat index sy-tabix.
endif.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = P_TITLE
I_SELECTION = 'X'
I_ZEBRA = ' '
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_CHECKBOX_FIELDNAME =
I_LINEMARK_FIELDNAME =
I_SCROLL_TO_SEL_LINE = 'X'
i_tabname = '1'
IT_FIELDCAT = gt_fieldcat[]
IT_EXCLUDING =
I_CALLBACK_PROGRAM =
I_CALLBACK_USER_COMMAND =
IS_PRIVATE = GS_PRIVATE
IMPORTING
ES_SELFIELD = GS_SELFIELD
E_EXIT = G_EXIT
TABLES
T_OUTTAB = GT_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE I000(0K) WITH SY-SUBRC.
ENDIF.
WRITE: / G_EXIT, GS_SELFIELD.
11-16-2005 6:30 PM
Hi Please go through the code and check it.
FUNCTION z_calc.
*"----
""Local interface:
*" IMPORTING
*" VALUE(P_SUMMARY_LEVEL) TYPE ZPRC_SIM_HDR-SIM_TYPE
*" VALUE(P_PLTYP) TYPE ZPRICELIST-PLTYP
*" VALUE(P_EFF_DATE) TYPE ZPRICELIST-ZZEFFDTE
*" VALUE(P_RET_SUMM) TYPE CHAR1 OPTIONAL
*" TABLES
*" IT_MATTAB STRUCTURE ZPRC_MAT_SALES
*" IT_SUMM_RESULTS STRUCTURE ZPRC_SUMM_SALES OPTIONAL
*" IT_HEADER STRUCTURE ZPRC_SIM_HDR
*" EXCEPTIONS
*" INVALID_SUMM_LEVEL
*"----
----
**********************************************************************
Database Tables
**********************************************************************
TABLES : mvke, "Sales Data for Material
mara, "General Material Data
zprc_appl_sales. "Price Adjustment Application
"Sales/Volume Data
**********************************************************************
Variables
**********************************************************************
DATA: v_tier1 TYPE kbetr_kond,
v_tier2 TYPE kbetr_kond,
v_tier3 TYPE kbetr_kond,
v_char_value LIKE bapi_object_values-char_value," char value
v_tabix LIKE sy-tabix, " index
v_count TYPE i, " counter
v_count1(3), " counter
v_dummy, " dummy variable
v_round TYPE p.
**********************************************************************
Constants
**********************************************************************
CONSTANTS :
c_pr_line(21) VALUE 'PRODUCT_HIERARCHY_005',
c_afts_sub(21) VALUE 'PRODUCT_HIERARCHY_010',
c_pcc(21) VALUE 'PRODUCT_HIERARCHY_006',
c_mkt_grp(21) VALUE 'PRODUCT_HIERARCHY_002',
c_afts(21) VALUE 'PRODUCT_HIERARCHY_009',
c_vkorg LIKE mvke-vkorg VALUE '1000',
"Sales organization
c_vtweg LIKE mvke-vtweg VALUE '10',
"Distribution Channel
c_cl_only TYPE bapiflag VALUE 'X',
"Chars of Class Only
c_sum_p TYPE zprc_sim_hdr-sim_type VALUE 'P', "Product Line
c_sum_s TYPE zprc_sim_hdr-sim_type VALUE 'S', "AFTS Sub-Category
c_cl_type LIKE bapi_class_key-classtype VALUE '001', " Class Type
c_cl_num LIKE bapi_class_key-classnum VALUE 'PRODUCT_HIERARCHY'.
"Product Hierarchy
**********************************************************************
Internal Tables
**********************************************************************
*- internal table for processing materials in IT_MATTAB
DATA:BEGIN OF it_data OCCURS 0,
matnr_value TYPE zprc_summ_sales-summ_value,
mkt_grp TYPE zprc_summ_sales-summ_value,
afts TYPE zprc_summ_sales-summ_value,
prod_ln TYPE zprc_summ_sales-summ_value,
pcc TYPE zprc_summ_sales-summ_value,
afts_sub TYPE zprc_summ_sales-summ_value.
INCLUDE STRUCTURE zprc_mat_sales.
DATA:
current_ndn TYPE zprc_appl_sales-qty,
new_ndn TYPE zprc_appl_sales-qty,
discount_pct(4) TYPE p DECIMALS 2,
current_net_net TYPE zprc_appl_sales-qty,
new_ndn_curr_vol TYPE zprc_appl_sales-qty,
new_net_net_curr_vol TYPE zprc_appl_sales-qty,
new_ndn_new_vol TYPE zprc_appl_sales-qty,
new_net_net_new_vol TYPE zprc_appl_sales-qty,
END OF it_data.
*- error table
DATA it_error LIKE zerrtable OCCURS 0 WITH HEADER LINE.
*- object classification table
DATA it_char_val LIKE bapi_object_values OCCURS 0 WITH HEADER LINE.
*- class objects table
DATA: it_cl_ob LIKE bapi_class_objects OCCURS 0 WITH HEADER LINE.
*- field catalog
DATA : it_fieldcat_popup TYPE slis_t_fieldcat_alv,
x_fieldcat TYPE slis_fieldcat_alv.
*- Material Pricing Group
DATA: BEGIN OF it_kondm OCCURS 0,
matnr LIKE mvke-matnr,
kondm LIKE mvke-kondm,
END OF it_kondm.
*- Material Group
DATA: BEGIN OF it_matkl OCCURS 0,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
END OF it_matkl.
DATA: BEGIN OF it_char_desc OCCURS 0,
char_value(30),
descr_cval(30),
END OF it_char_desc.
STC002 Insert
Added internal table to calculate summary percent when forecast volume has
been used in simulation.
DATA: BEGIN OF it_summary OCCURS 0,
summ_value TYPE zprc_summ_sales-summ_value,
nn_new_list_new_vol TYPE zprc_summ_sales-nn_new_list_new_vol,
summ_value_pct TYPE p DECIMALS 4,
END OF it_summary.
DATA: v_total_vol TYPE zprc_summ_sales-nn_new_list_new_vol.
DATA: v_forecast_percent TYPE p DECIMALS 4.
DATA: v_calc TYPE p DECIMALS 4.
STC002 End Insert
CLEAR it_summ_results.
REFRESH it_summ_results.
CLEAR it_summary.
REFRESH it_summary.
REFRESH it_output.
CLEAR: it_output,v_char_desc.
REFRESH it_sim_header.
CLEAR it_sim_header.
it_sim_header[] = it_header[].
IF NOT it_mattab[] IS INITIAL.
*- fetch Material Pricing Group
SELECT matnr kondm INTO CORRESPONDING FIELDS OF TABLE
it_kondm FROM mvke
FOR ALL ENTRIES IN it_mattab
WHERE matnr = it_mattab-matnr
AND vkorg = c_vkorg
AND vtweg = c_vtweg
AND lvorm = ' '.
*- fetch Material Group
SELECT matnr matkl INTO CORRESPONDING FIELDS OF TABLE
it_matkl FROM mara
FOR ALL ENTRIES IN it_mattab
WHERE matnr = it_mattab-matnr
AND lvorm = ' ' .
ENDIF.
IF p_ret_summ <> 'X'.
*- Either Product Line or AFTS Sub-Category
IF p_summary_level <> c_sum_p AND p_summary_level <> c_sum_s.
MESSAGE e027(vv) RAISING invalid_summ_level.
MESSAGE e160(vv) RAISING invalid_summ_level. "<--Enterprise
" Invalid Price Adjustment Record Types
ENDIF.
ENDIF.
Sort Tables
SORT it_kondm BY matnr.
SORT it_matkl BY matnr.
IF p_ret_summ <> 'X'.
*- if Product line
IF p_summary_level = c_sum_p.
v_char_value = c_pr_line.
ELSE.
*- if AFTS Sub-Category
v_char_value = c_afts_sub.
ENDIF.
ENDIF.
*- loop through internal table
LOOP AT it_mattab.
*- delete all table entries
REFRESH : it_cl_ob,
it_error,
it_char_val.
*- clear headers
CLEAR : mvke,
mara,
it_data,
it_kondm,
it_matkl,
zprc_appl_sales.
*- clear variables
CLEAR : v_tier1, v_tier2, v_tier3.
*- Read Material Pricing Group
READ TABLE it_kondm WITH KEY matnr = it_mattab-matnr
BINARY SEARCH TRANSPORTING kondm .
*- Read Material Group
READ TABLE it_matkl WITH KEY matnr = it_mattab-matnr
BINARY SEARCH TRANSPORTING matkl.
*- call function module for char value table
CALL FUNCTION 'Z_GET_MATL_PRICING_NDNS'
EXPORTING
material = it_mattab-matnr
vkorg = c_vkorg
prlist = p_pltyp
eff_date = p_eff_date
mvke_kondm = it_kondm-kondm
matkl = it_matkl-matkl
IMPORTING
tier1 = v_tier1
tier2 = v_tier2
tier3 = v_tier3
TABLES
zerrtable = it_error
st_char_val = it_char_val.
*- if error table is populated, skip to next material
IF NOT it_error[] IS INITIAL.
CONTINUE.
ENDIF.
*- if char value table is empty
IF it_char_val[] IS INITIAL.
*- populate with object key value
MOVE it_mattab-matnr TO it_cl_ob-object_key.
APPEND it_cl_ob.
*- call function for char value table
CALL FUNCTION 'BAPI_CLASS_GET_CLASSIFICATIONS'
EXPORTING
classtype = c_cl_type
classnum = c_cl_num
key_date = p_eff_date
characts_of_class_only = c_cl_only
TABLES
object_classification = it_char_val
class_objects = it_cl_ob.
ENDIF.
*- assign values
it_data-matnr = it_mattab-matnr.
it_data-curr_list = it_mattab-curr_list.
it_data-curr_volume = it_mattab-curr_volume.
it_data-new_list = it_mattab-new_list.
it_data-new_volume = it_mattab-new_volume.
*- Format tier %. Set the tiers containing 0 to 1 so they may
be used in multiplying the tier factor without checking to
see if > 0.
v_tier1 = 1 - v_tier1.
IF v_tier2 > 0.
v_tier2 = 1 - v_tier2.
ELSE.
v_tier2 = 1.
ENDIF.
IF v_tier3 > 0.
v_tier3 = 1 - v_tier3.
ELSE.
v_tier3 = 1.
ENDIF.
*- current NDN
it_data-current_ndn = v_tier1 * it_mattab-curr_list.
it_data-current_ndn = v_tier2 * it_data-current_ndn.
it_data-current_ndn = v_tier3 * it_data-current_ndn.
it_data-current_ndn = it_data-current_ndn * it_mattab-curr_volume.
*- new NDN - take current tiers and apply to new list price. Volume is
intentionally left out of calculation for new NDN because both
current and new values are considered against the new NDN.
it_data-new_ndn = v_tier1 * it_mattab-new_list.
it_data-new_ndn = v_tier2 * it_data-new_ndn.
it_data-new_ndn = v_tier3 * it_data-new_ndn.
*- sort the table
SORT it_char_val BY name_char.
IF p_ret_summ <> 'X'.
READ TABLE it_char_val WITH KEY name_char = v_char_value
BINARY SEARCH TRANSPORTING char_value descr_cval.
*- assign Characteristic Value to Material Value
IF sy-subrc = 0.
it_data-matnr_value = it_char_val-char_value.
it_char_desc-char_value = it_char_val-char_value.
it_char_desc-descr_cval = it_char_val-descr_cval.
APPEND it_char_desc.
ENDIF.
*- This will preserve all of the hierarchy fields which are
used within the price adjustment application criteria screen.
These fields are only passed back within the summarization
table.
ELSE.
READ TABLE it_char_val WITH KEY name_char = c_pr_line
BINARY SEARCH.
IF sy-subrc = 0.
it_data-prod_ln = it_char_val-descr_cval.
ENDIF.
READ TABLE it_char_val WITH KEY name_char = c_afts_sub
BINARY SEARCH.
IF sy-subrc = 0.
it_data-afts_sub = it_char_val-descr_cval.
ENDIF.
READ TABLE it_char_val WITH KEY name_char = c_pcc
BINARY SEARCH.
IF sy-subrc = 0.
it_data-pcc = it_char_val-descr_cval.
ENDIF.
READ TABLE it_char_val WITH KEY name_char = c_mkt_grp
BINARY SEARCH.
IF sy-subrc = 0.
it_data-mkt_grp = it_char_val-descr_cval.
ENDIF.
READ TABLE it_char_val WITH KEY name_char = c_afts
BINARY SEARCH.
IF sy-subrc = 0.
it_data-afts = it_char_val-descr_cval.
ENDIF.
ENDIF.
*- fetch NDN and net_net
SELECT SINGLE ndn net_net FROM zprc_appl_sales
INTO (zprc_appl_sales-ndn ,
zprc_appl_sales-net_net)
WHERE matnr = it_mattab-matnr.
*- Calculate discount percentage based on current sales NDN and
net net if there is current NDN.
IF zprc_appl_sales-ndn <> 0.
it_data-discount_pct = ( zprc_appl_sales-ndn -
zprc_appl_sales-net_net )
/ zprc_appl_sales-ndn.
it_data-discount_pct = 1 - it_data-discount_pct.
STC002 Insert
Find a default discount % but ONLY where no current sales data
exists for style number AND where user has supplied a forecast
volume (it_data-new_volume). In this case, we will default to
full price (no discount).
ELSE.
IF it_data-curr_volume = 0 AND
it_data-new_volume > 0.
it_data-discount_pct = 1.
ENDIF.
STC002 End Insert
ENDIF.
*- current net to net value
it_data-current_net_net = it_data-discount_pct
it_data-current_ndn.
*- new NDN current volume
it_data-new_ndn_curr_vol = it_data-new_ndn
it_data-curr_volume.
*-
it_data-new_net_net_curr_vol = it_data-discount_pct
it_data-new_ndn_curr_vol.
*- new NDN new volume
it_data-new_ndn_new_vol = it_data-new_ndn
it_data-new_volume.
*-
it_data-new_net_net_new_vol = it_data-discount_pct
it_data-new_ndn_new_vol.
IF p_ret_summ = 'X'.
CLEAR it_summ_results.
it_summ_results-nn_curr_list_curr_vol
= it_data-current_net_net.
it_summ_results-nn_new_list_curr_vol
= it_data-new_net_net_curr_vol.
it_summ_results-nn_new_list_new_vol
= it_data-new_net_net_new_vol.
it_summ_results-mkt_grp = it_data-mkt_grp.
it_summ_results-afts = it_data-afts.
it_summ_results-prod_ln = it_data-prod_ln.
it_summ_results-pcc = it_data-pcc.
it_summ_results-afts_sub = it_data-afts_sub.
APPEND it_summ_results.
ENDIF.
*- add new record
APPEND it_data.
*- clear headers
CLEAR it_mattab.
ENDLOOP.
No need to go further if only thing requested is a list of summary
entries, which is normally only needed for overall price adjustment
statistics.
IF p_ret_summ = 'X'.
EXIT.
ENDIF.
*- sort by material value.
SORT it_data BY matnr_value.
LOOP AT it_data.
v_tabix = sy-tabix.
*- summarize the fields for each unique value of matnr_value and make
*- any entry in summary table
AT END OF matnr_value.
READ TABLE it_data INDEX v_tabix.
SUM.
CLEAR v_round.
MOVE it_data-matnr_value TO it_summ_results-summ_value.
MOVE it_data-current_net_net TO
it_summ_results-nn_curr_list_curr_vol.
MOVE it_summ_results-nn_curr_list_curr_vol TO v_round.
MOVE v_round TO it_summ_results-nn_curr_list_curr_vol.
CLEAR v_round.
MOVE it_data-new_net_net_curr_vol TO
it_summ_results-nn_new_list_curr_vol.
MOVE it_summ_results-nn_new_list_curr_vol TO v_round.
MOVE v_round TO it_summ_results-nn_new_list_curr_vol.
CLEAR v_round.
MOVE it_data-new_net_net_new_vol TO
it_summ_results-nn_new_list_new_vol.
MOVE it_summ_results-nn_new_list_new_vol TO v_round.
MOVE v_round TO it_summ_results-nn_new_list_new_vol.
STC002 Summarize forecasted volume also.
MOVE it_data-new_volume to it_summ_results-new_volume.
CLEAR v_round.
MOVE it_data-new_volume TO
it_summ_results-new_volume.
MOVE it_summ_results-new_volume TO v_round.
MOVE v_round TO it_summ_results-new_volume.
STC002 End Insert
APPEND it_summ_results. " append record
CLEAR it_summ_results. " clear header
ENDAT.
ENDLOOP.
*- loop through internal table
LOOP AT it_summ_results.
v_tabix = sy-tabix.
IF it_summ_results-nn_curr_list_curr_vol <> 0.
it_output-a is list price change
it_output-a = ( ( it_summ_results-nn_new_list_curr_vol /
it_summ_results-nn_curr_list_curr_vol ) - 1 ) * 100.
ENDIF.
it_output-b is Total discounted sales at current list
WRITE it_summ_results-nn_curr_list_curr_vol TO it_output-b.
SPLIT it_output-b AT '.' INTO it_output-b v_dummy.
it_output-c is Total discounted sales at new list
WRITE it_summ_results-nn_new_list_curr_vol TO it_output-c.
SPLIT it_output-c AT '.' INTO it_output-c v_dummy.
IF it_summ_results-nn_curr_list_curr_vol <> 0.
STC002 Insert
Added check to see if current and forecast volume are same. If so,
apply same calculation as for it_output-a which is % List Price change.
IF it_summ_results-nn_new_list_curr_vol =
it_summ_results-nn_new_list_new_vol.
it_output-d is % List Price change based on forecast volume
it_output-d = ( ( it_summ_results-nn_new_list_new_vol /
it_summ_results-nn_curr_list_curr_vol ) - 1 ) * 100.
v_forecast_percent = it_output-d.
ELSE.
If volumes differ, this means that user input forecast volumes into the
tool. In this case, must find weighted percent for each style number based
on forecast and calculate overall weighted percent.
Here is an example:
*
Style Current list New List % Chg Volume Forecast
XLF18302P $1191 $1251 5.04 0 1691
XLF18362P $1371 $1440 5.03 0 836
X2G236RPEN $2187 $2296 4.98 0 0
X2G236WPEN $2187 $2296 4.98 2 2
*
So the sum of all forecast volumes is 2529. The first style XLF18302P
is 1691 / 2529 (67%) of total. Apply this fraction to percent of 5.04 to
get a weighted percent. Continue with each style in this fashion. For the
above, the weighted percent will come out to be 5.037 %.
v_forecast_percent = 0.
v_calc = 0.
LOOP AT it_data WHERE matnr_value = it_summ_results-summ_value.
v_calc = ( ( it_data-new_list - it_data-curr_list ) /
it_data-curr_list ) * 100.
v_calc = v_calc * ( it_data-new_volume / it_summ_results-new_volume ).
v_forecast_percent = v_forecast_percent + v_calc.
ENDLOOP.
it_output-d is % List Price change based on forecast volume
it_output-d = v_forecast_percent.
ENDIF.
it_summary-summ_value = it_summ_results-summ_value.
it_summary-summ_value_pct = v_forecast_percent.
it_summary-nn_new_list_new_vol = it_summ_results-nn_new_list_new_vol.
v_total_vol = v_total_vol + it_summ_results-nn_new_list_new_vol.
APPEND it_summary.
STC002 End Insert
ENDIF.
READ TABLE it_char_desc WITH KEY
char_value = it_summ_results-summ_value.
it_output-value = it_char_desc-descr_cval.
it_output-e is Total discounted sales for forecast at new list
WRITE it_summ_results-nn_new_list_new_vol TO it_output-e.
SPLIT it_output-e AT '.' INTO it_output-e v_dummy.
APPEND it_output.
AT LAST.
Put final totals line logic here.
READ TABLE it_summ_results INDEX v_tabix.
SUM.
IF it_summ_results-nn_curr_list_curr_vol <> 0 AND
it_summ_results-nn_new_list_curr_vol <> 0.
it_output-a = ( ( it_summ_results-nn_new_list_curr_vol /
it_summ_results-nn_curr_list_curr_vol ) - 1 ) * 100.
ENDIF.
IF it_summ_results-nn_curr_list_curr_vol <> 0 AND
it_summ_results-nn_new_list_new_vol <> 0.
If current volume and forecast volume same, then % is same. This means
that user did not put any forecast numbers into the simulation(s).
IF it_summ_results-nn_new_list_curr_vol =
it_summ_results-nn_new_list_new_vol.
it_output-d = ( ( it_summ_results-nn_new_list_new_vol /
it_summ_results-nn_curr_list_curr_vol ) - 1 ) * 100.
ELSE.
STC002 Insert
If volumes differ, this means that user input forecast volumes into the
tool. In this case, must find weighted percent for each group (Product line
or AFTS Sub-category) and calculate overall weighted percent. This is for
the totals line at the bottom of weighted averages report.
v_forecast_percent = 0.
LOOP AT it_summary.
v_forecast_percent = v_forecast_percent +
( ( it_summary-nn_new_list_new_vol / v_total_vol ) *
it_summary-summ_value_pct ).
ENDLOOP.
it_output-d = v_forecast_percent.
STC002 End Insert
ENDIF.
*
ENDIF.
WRITE : it_summ_results-nn_curr_list_curr_vol TO it_output-b,
it_summ_results-nn_new_list_curr_vol TO it_output-c,
it_summ_results-nn_new_list_new_vol TO it_output-e.
SPLIT it_output-b AT '.' INTO it_output-b v_dummy.
SPLIT it_output-c AT '.' INTO it_output-c v_dummy.
SPLIT it_output-e AT '.' INTO it_output-e v_dummy.
it_output-value = 'Total'.
APPEND it_output.
ENDAT.
CLEAR : it_output.
ENDLOOP.
*- Display calculate averages popup
*- if Product line
IF p_summary_level = c_sum_p.
v_char_desc = 'Product Line'.
ELSE.
*- if AFTS Sub-Category
v_char_desc = 'AFTS Sub-Category'.
ENDIF.
DESCRIBE TABLE it_mattab LINES v_style.
<b> CALL SCREEN 500 STARTING AT 10 7
ENDING AT 100 20.</b>
ENDFUNCTION.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'ENTER'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
CLEAR: sy-ucomm.
----
***INCLUDE LZPD_PRCADJO01 .
----
************************************************************************
*
CHANGE HISTORY *
*
Date STC# Level Description Author *
-------- ------- ----- --------------------------------- -------- *
09/2005 STC001 Sort simulations and print total DPOLKOWS *
************************************************************************
&----
*& Module STATUS_9001 OUTPUT
&----
text
----
MODULE status_9001 OUTPUT.
SET PF-STATUS 'PRCSSIM'.
SET TITLEBAR 'SSIM'.
IF v_status_flag = 'X'.
LOOP AT SCREEN.
IF screen-name = 'R_PRIVATE'.
screen-output = '1'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
ENDMODULE. " STATUS_9001 OUTPUT
&----
*& Module STATUS_0500 OUTPUT
&----
text
----
MODULE status_0500 OUTPUT.
DATA : v_last TYPE sy-index.
DATA : v_sims TYPE i.
SET PF-STATUS 'CAL_AVG'.
SET TITLEBAR 'AVG'.
SUPPRESS DIALOG.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 500.
NEW-PAGE NO-TITLE NO-HEADING LINE-SIZE 183.
SORT it_sim_header BY ernam erdat erzet. "STC001
IF NOT it_sim_header[] IS INITIAL.
DESCRIBE TABLE it_sim_header LINES v_sims. "STC001
FORMAT COLOR 4.
WRITE:/ sy-uline(99).
WRITE:/ sy-vline,
2 'User Name',
14 sy-vline,
15 'Creation Date',
32 sy-vline,
33 'Creation Time',
47 sy-vline ,
48 'Description',
99 sy-vline.
WRITE:/ sy-uline(99).
FORMAT RESET.
LOOP AT it_sim_header.
WRITE:/ sy-vline,
2 it_sim_header-ernam,
14 sy-vline,
15 it_sim_header-erdat,
32 sy-vline,
33 it_sim_header-erzet,
47 sy-vline ,
48 it_sim_header-sim_desc,
99 sy-vline.
ENDLOOP.
WRITE:/ sy-uline(99).
ENDIF.
WRITE:/1 'Total # of Styles:' , 20 v_style .
STC001 Print total number of simulations if selecting a group.
IF v_sims > 1.
WRITE:/1 'Total # of Simulations:', 28 v_sims.
ENDIF.
WRITE:/ sy-uline(183).
WRITE:/ sy-vline,
32 sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 33.
FORMAT RESET.
FORMAT COLOR 4.
WRITE: 33 'Weighted Averages Based on',
117 sy-vline,
118 'Weighted Averages Based on',
183 sy-vline.
FORMAT RESET.
WRITE:/ sy-vline,
32 sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 33.
FORMAT COLOR 4.
WRITE: 33 'Historical Volumes',
117 sy-vline,
118 'Forecast Volumes',
183 sy-vline.
FORMAT RESET.
WRITE:/ sy-uline(183).
FORMAT COLOR 4.
WRITE:/ sy-vline,
2 v_char_desc,
32 sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 33.
WRITE: 33 '% List Price',
45 sy-vline,
46 '% Optional' COLOR 2 INTENSIFIED OFF,
46 '% Optional' color col_normal,
56 sy-vline,
57 '% Surf ' COLOR 2 INTENSIFIED OFF,
66 sy-vline,
67 'Total % List' COLOR 2 INTENSIFIED OFF,
79 sy-vline,
80 'Total Disc Sales',
98 sy-vline,
99 'Total Disc Sales',
117 sy-vline,
118 '% List Price',
130 sy-vline,
131 '% Optional' COLOR 2 INTENSIFIED OFF,
141 sy-vline,
142 '% Surf ' COLOR 2 INTENSIFIED OFF,
151 sy-vline,
152 'Total % List' COLOR 2 INTENSIFIED OFF,
164 sy-vline,
165 'Total Disc Sales' ,
183 sy-vline.
FORMAT RESET.
FORMAT COLOR 4.
WRITE:/ sy-vline,
32 sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 33.
WRITE: 33 'Chg ( req ',
45 sy-vline,
46 ' Option ' COLOR 2 INTENSIFIED OFF,
56 sy-vline,
57 ' Matl ' COLOR 2 INTENSIFIED OFF,
66 sy-vline,
67 ' Price ' COLOR 2 INTENSIFIED OFF,
79 sy-vline,
80 'at Current List',
98 sy-vline,
99 'at Adjusted',
117 sy-vline,
118 'Chg ( req ',
130 sy-vline,
131 ' Option ' COLOR 2 INTENSIFIED OFF,
141 sy-vline,
142 ' Matl ' COLOR 2 INTENSIFIED OFF,
151 sy-vline,
152 ' Price ' COLOR 2 INTENSIFIED OFF ,
164 sy-vline,
165 'at Adjusted',
183 sy-vline.
FORMAT RESET.
FORMAT COLOR 4.
WRITE:/ sy-vline,
32 sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 33.
WRITE: 33 ' opt only )',
45 sy-vline,
46 ' Chg ' COLOR 2 INTENSIFIED OFF,
56 sy-vline,
57 ' Chg ' COLOR 2 INTENSIFIED OFF ,
66 sy-vline,
67 ' Chg ' COLOR 2 INTENSIFIED OFF ,
79 sy-vline,
80 'Prices',
98 sy-vline,
99 'List Prices',
117 sy-vline,
118 'opt only )',
130 sy-vline,
131 ' Chg ' COLOR 2 INTENSIFIED OFF ,
141 sy-vline,
142 ' Chg ' COLOR 2 INTENSIFIED OFF,
151 sy-vline,
152 ' Chg ' COLOR 2 INTENSIFIED OFF ,
164 sy-vline,
165 'List Prices' ,
183 sy-vline.
WRITE:/ sy-uline(183).
FORMAT RESET.
CLEAR v_last.
DESCRIBE TABLE it_output LINES v_last.
LOOP AT it_output.
WRITE it_output-b TO it_output-b RIGHT-JUSTIFIED.
WRITE it_output-c TO it_output-c RIGHT-JUSTIFIED.
WRITE it_output-e TO it_output-e RIGHT-JUSTIFIED.
IF v_last = sy-tabix.
FORMAT COLOR 3.
WRITE:/ sy-uline(183).
WRITE:/ sy-vline,
2 it_output-value,
32 sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 33.
f,g,h,i,j and k columns are having blank data at this point of time
as they are for future purpose.
WRITE: 33 it_output-a,
45 sy-vline,
46 ' ' , "it_output-f
56 sy-vline,
57 ' ', "it_output-g
66 sy-vline,
67 ' ', " it_output-h
79 sy-vline,
80 it_output-b,
98 sy-vline,
99 it_output-c,
117 sy-vline,
118 it_output-d,
130 sy-vline,
131 ' ', "it_output-i
141 sy-vline,
142 ' ' , "it_output-j
151 sy-vline,
152 ' ', "it_output-k
164 sy-vline,
165 it_output-e ,
183 sy-vline.
ELSE.
WRITE:/ sy-vline,
2 it_output-value,
32 sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 33.
WRITE: 33 it_output-a,
45 sy-vline,
46 '' ,
56 sy-vline,
57 '' ,
66 sy-vline,
67 '' ,
79 sy-vline,
80 it_output-b,
98 sy-vline,
99 it_output-c,
117 sy-vline,
118 it_output-d,
130 sy-vline,
131 '' ,
141 sy-vline,
142 '' ,
151 sy-vline,
152 '' ,
164 sy-vline,
165 it_output-e ,
183 sy-vline.
ENDIF.
ENDLOOP.
IF sy-subrc <> 0.
WRITE:/ sy-vline,
'No Data',
183 sy-vline.
ENDIF.
WRITE:/ sy-uline(183).
LEAVE SCREEN. "ITIGIN08
ENDMODULE. " STATUS_0500 OUTPUT
&----
*& Module USER_COMMAND_0500 INPUT
&----
MODULE user_command_0500 INPUT.
CASE sy-ucomm.
WHEN 'ENTER'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
CLEAR: sy-ucomm.
ENDMODULE. " USER_COMMAND_0500 INPUT
Message was edited by: Vijay Babu Dudla