Very Urgent: how to define field symbols in class using se24 Points assured
hi all
I am new to abap oo programming. I am using se24 to build a class
where some methods have code which involves working with field sybmols but i am not able to figure out way for how to define field symbols in the attributes section.
I tried defining like : fld_sym type ref to dbtab-fld
but in the method implementation if i try to use it like assign fld to <fld_sym> there it says fld_sym is not defined as a field symbol.
So can anyone please guide me how to define field symbols in se24.
Also what should be the general steps while creating a class using se24.
Points assured
thanks
Hi
Global classes are like Global fun modules in which the Methods and code is already written and is mainly used for Reusability purpose.
Goto SE24 tcode and see the std global classes like
CL_ABAP_CHAR_UTILITIES
see the links
chk out the links below:
General Tutorial for OOPS
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
Have a look at these links for OO ABAP.
http://www.sapgenie.com/abap/OO/
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.allsaplinks.com/
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
SDN Series:
https://www.sdn.sap.com/irj/sdn/developerareas/abap?rid=/webcontent/uuid/35eaef9c-0b01-0010-dd8b-e3b0f9ed7ccb [original link is broken]
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf
Basic concepts of OOPS
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1591ec90-0201-0010-3ba8-cdcd500b17cf
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20display%20data%20in%20alv%20grid%20using%20object%20oriented%20programming.doc
http://www.henrikfrank.dk/abapuk.html
http://www.erpgenie.com/abap/OO/
Reward oints if useful,
Aleem.
Similar Messages
-
Define Field Symbols Dynamically
Hi,
Is it possible to define field symbols dynamically based on some naming convention? If yes, please let me know how to do that.
Thanks & Best Regards,
Kumar.I have this code in a loop that does this
CONCATENATE 'TYPE' zlmltyp-ztext_key '_' zlmstyp-scrnseq
INTO wk_fldname.
CONCATENATE wk_fldname '-DATE' INTO fldname.
ASSIGN (fldname) TO <text_fld>.
<text_fld> = wa_zlmstat-erdat.
CONCATENATE wk_fldname '-CURR_STATUS' INTO fldname.
ASSIGN (fldname) TO <text_fld>.
IF wa_zlmstat-ltype = zlmlead-ltype
AND wa_zlmstat-status = zlmlead-status.
<text_fld> = 'X'.
ELSE.
CLEAR <text_fld>.
ENDIF.
the fields are defined like this
DATA:
BEGIN OF scrn_stat_rec,
ltype TYPE zlmltype,
status TYPE zlmstatus,
descrip TYPE zstypex,
date LIKE sy-datum,
curr_status TYPE c,
specstatdate TYPE z_scrn_date,
auth TYPE zlmauth,
END OF scrn_stat_rec,
type100_01 LIKE scrn_stat_rec,
type100_02 LIKE scrn_stat_rec,
type100_03 LIKE scrn_stat_rec,
type100_04 LIKE scrn_stat_rec,
type100_05 LIKE scrn_stat_rec,
type100_06 LIKE scrn_stat_rec,
type100_07 LIKE scrn_stat_rec,
type100_08 LIKE scrn_stat_rec,
type100_09 LIKE scrn_stat_rec,
type100_10 LIKE scrn_stat_rec,
type200_01 LIKE scrn_stat_rec,
*** all the way to
type600_09 LIKE scrn_stat_rec,
type600_10 LIKE scrn_stat_rec,
type700_01 LIKE scrn_stat_rec,
type700_02 LIKE scrn_stat_rec,
type700_03 LIKE scrn_stat_rec,
type700_04 LIKE scrn_stat_rec,
type700_05 LIKE scrn_stat_rec,
type700_06 LIKE scrn_stat_rec,
type700_07 LIKE scrn_stat_rec,
type700_08 LIKE scrn_stat_rec,
type700_09 LIKE scrn_stat_rec,
type700_10 LIKE scrn_stat_rec. -
Very Urgent : How to retrieve a SAP Script
Hi Guys it is very urgent...I over wrote a form using the SCC1 transaction....I copied it from the wrong client into my development client...So it overwrote my Script..Is there any way i can retrieve it...
go to your quality system download your script by using program RSTXSCRP.
then upload it into your devlopment system. -
Field-symbols as class attribute
Hi Fellas,
Is there a way we can define a field-symbols as a class attribute ? My requirement is that i am dynamically constructing a structure at runtime in my model class and binding the component of this structure to my view fields. I am able to create the structure which is basically ref to cl_abap_structdescr and the problem is when i am binding to the model attribute, i need this to be a structure so that i can address the components as "//model/structure.component".
Please let me know how we can define a field-symbol as a class attribute.
Cheers,
Ram.Hi Ram,
Field-Symbol as class attribute is not possible. Your way to do this by REF TO DATA is the correct way for that.
By default data binding is only possible like this:
Simple field attribute
value=//<model>/<field name>
Structure attribute
value=//<model>/<structure name>.<field name>
Table attribute
value=//<model>/<table name>[<line index].<field name>
If you want to bind to your data reference you have to implement your own getter and setter methods. Read this <a href="http://help.sap.com/saphelp_nw70/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm">http://help.sap.com/saphelp_nw70/helpdata/en/fb/fbb84c20df274aa52a0b0833769057/frameset.htm</a> for further information. In addition to that, you have to implement your own GET_M_S_xxx to return metadata of your structure. By doing all this it is possible to implement a completely dynamic data binding. In the view it looks like the regular Structure attribute: value=//<model>/<data-ref name>.<field name>
Regards,
Thilo -
Field symbols as Class Attributes
Hello Gurus,
Is anybody able to say to me if it is possible to declare field symbols as class attributes? As I can understand until now, this is not possible and we need to use some attribute with the "TYPE REF TO Data" to get the information we need. Correct?
Thanks,
Daniel.Ok, let me see if someone can give me some idea on how to improve my method:
Method: PREPARE_PTOOL_DATA
Parameters specification:
Parameter Type Typing Reference Type
PF_ANALYSIS Importing Type /SYM/SC_PT_ID_ANALYSIS_D
PF_ANAL_DESC Importing Type /SYM/SC_NM_DESC_ANALYSIS
PF_LOGIC Importing Type CHAR01
PF_MATERIAL Importing Type MATNR
PF_MAKTX Importing Type MAKTX
PT_DATA_COMPA Exporting Type /SYM/SC_TAB_PT_RESULT_CP
PT_CALC_ANALY Exporting Type /SYM/SC_TAB_PT_RESULT_CA
PT_DATA_MATERIAL1 Changing Type /SYM/SC_TAB_PROC_ALLERG_RESULT
PT_DATA_MATERIAL2 Changing Type /SYM/SC_TAB_PROC_ALLERG_RESULT
Source code:
From the /SYM/SC_CL_PROCESS_ALLERG_GEN class
Old version (but it is working)
METHOD prepare_ptool_data.
DATA: ls_data_material1 TYPE /sym/sc_s_proc_allerg_result,
ls_data_material2 TYPE /sym/sc_s_proc_allerg_result,
lf_index_material1 TYPE sy-tabix,
lf_index_material2 TYPE sy-tabix,
ls_result_cp TYPE /sym/sc_pt_result_cp,
ls_result_ca TYPE /sym/sc_pt_result_ca.
Prepare data for Data Comparison step
IF pt_data_compa IS REQUESTED.
LOOP AT pt_data_material1 INTO ls_data_material1.
lf_index_material1 = sy-tabix.
CLEAR ls_result_cp.
MOVE pf_analysis TO ls_result_cp-analysis.
MOVE pf_anal_desc TO ls_result_cp-desc_analysis.
MOVE ls_data_material1-algbe TO ls_result_cp-desc_property.
If Logic 'A', move the text from ls_data_material1 to original
material status
IF pf_logic EQ c_logic_a.
MOVE ls_data_material1-agsbe TO ls_result_cp-val_orig_matnr.
If Logic 'B', move the text from ls_data_material1 to "toy"
material status
ELSEIF pf_logic EQ c_logic_b.
MOVE ls_data_material1-agsbe TO ls_result_cp-val_toy_matnr.
ENDIF. " IF pf_logic EQ c_logic_a.
Read the lt_data_toy by the Allergen ID (ALGEN)
CLEAR ls_data_material2.
READ TABLE pt_data_material2 INTO ls_data_material2
WITH KEY algen = ls_data_material1-algen BINARY SEARCH.
IF sy-subrc EQ 0.
lf_index_material2 = sy-tabix.
If Logic 'A', move the text from ls_data_material2 to "toy°
material status
IF pf_logic EQ c_logic_a.
MOVE ls_data_material2-agsbe TO ls_result_cp-val_toy_matnr.
If Logic 'B', move the text from ls_data_material2 to original
material status
ELSEIF pf_logic EQ c_logic_b.
MOVE ls_data_material2-agsbe TO ls_result_cp-val_orig_matnr.
ENDIF. " IF pf_logic EQ c_a.
Delete record from lt_data_toy, index lf_index_toy
DELETE pt_data_material2 INDEX lf_index_material2.
ENDIF. " IF sy-subrc EQ 0.
APPEND ls_result_cp TO pt_data_compa.
Delete record from lt_data_orig, index lf_index_orig
DELETE pt_data_material1 INDEX lf_index_material1.
ENDLOOP. " LOOP AT lt_data_material1 INTO ls_data_material1.
ENDIF. " IF pt_data_compa IS REQUESTED.
Prepare data for Calculation Analysis step
IF pt_calc_analy IS REQUESTED.
LOOP AT pt_data_material1 INTO ls_data_material1.
lf_index_material1 = sy-tabix.
CLEAR ls_result_ca.
MOVE pf_material TO ls_result_ca-matnr.
MOVE pf_maktx TO ls_result_ca-maktx.
MOVE pf_analysis TO ls_result_ca-analysis.
MOVE pf_anal_desc TO ls_result_ca-desc_analysis.
MOVE ls_data_material1-algbe TO ls_result_ca-desc_property.
If Logic 'A', move the text from ls_data_material1 to original
material status
IF pf_logic EQ c_logic_a.
MOVE ls_data_material1-agsbe TO ls_result_ca-val_curr_stat.
If Logic 'B', move the text from ls_data_material1 to "toy"
material status
ELSEIF pf_logic EQ c_logic_b.
MOVE ls_data_material1-agsbe TO ls_result_ca-val_simul_stat.
ENDIF. " IF pf_logic EQ c_logic_a.
Read the lt_data_toy by the Allergen ID (ALGEN)
CLEAR ls_data_material2.
READ TABLE pt_data_material2 INTO ls_data_material2
WITH KEY algen = ls_data_material1-algen BINARY SEARCH.
IF sy-subrc EQ 0.
lf_index_material2 = sy-tabix.
If Logic 'A', move the text from ls_data_material2 to "toy°
material status
IF pf_logic EQ c_logic_a.
MOVE ls_data_material2-agsbe TO ls_result_ca-val_simul_stat.
If Logic 'B', move the text from ls_data_material2 to original
material status
ELSEIF pf_logic EQ c_logic_b.
MOVE ls_data_material2-agsbe TO ls_result_ca-val_curr_stat.
ENDIF. " IF pf_logic EQ c_a.
Delete record from lt_data_toy, index lf_index_toy
DELETE pt_data_material2 INDEX lf_index_material2.
ENDIF. " IF sy-subrc EQ 0.
APPEND ls_result_ca TO pt_calc_analy.
Delete record from lt_data_orig, index lf_index_orig
DELETE pt_data_material1 INDEX lf_index_material1.
ENDLOOP. " LOOP AT lt_data_material1 INTO ls_data_material1.
ENDIF. " IF pt_calc_analy IS REQUESTED.
ENDMETHOD.
As you can see, I am repeating almost the same code, just changing some items. I am not sure if I can use new parameters (ANY or ANY TABLE) but, my first idea to improve it was to use the field-symbols (and it works ok). The issue is that I have to repeat the assignment lines every same named method of the classes I am changing (I would like to do the assignment into a new method of the superclass). Do you think it is possible or should I give up and proceed with the assignments locally, for each same named method of each class?
Thanks,
Daniel. -
Hello,
Is it possible to use field-symbols in classes?
When I try to declare field-symbol in class like other variable, appears an error.
Or may be it is possible to use something instead of field-symbols?
Great thanx in advance!Hi
You can use field symbols in classes.
Sample code is given below:
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS m1 IMPORTING oref TYPE REF TO object
attr TYPE string.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD m1.
FIELD-SYMBOLS <attr> TYPE ANY.
ASSIGN oref->(attr) TO <attr>.
WRITE <attr> ...
ENDMETHOD.
ENDCLASS.
Thanks
Khushboo -
Is it possible to declare field symbols inside classes?
Thanks in advance.
Hema
Moderator message: please search for information and try yourself before asking.
Edited by: Thomas Zloch on Dec 23, 2010 10:55 AMHi Hemalatha,
We can use Field Symbols in classes.
local field_symbols within methods are allowed.
you can only use field-symbols within method (locally), not as direct class attribute (globally).
U can check with this sample code.
Sample code is given below:
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS m1 IMPORTING oref TYPE REF TO object attr TYPE string.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD m1.
FIELD-SYMBOLS <attr> TYPE ANY.
ASSIGN oref->(attr) TO <attr>.
WRITE <attr> ...
ENDMETHOD.
ENDCLASS.
I hope u got this ..... -
How to pass field symbol or table from one view to another view in abap web dynpro?
I am creating an Inbound Outbound ALV report in ABAP Web Dynpro. However at selection-screen I have select options and fetching is done at view2. Problem is we can pass parameter using inbound outbound parameters but how to pass internal table or field-symbols from one view to another view? I made use of Assistance Class too but its not very clear to me. Please give me some example or code to sort this problem out.
I am creating an Inbound Outbound ALV report in ABAP Web Dynpro. However at selection-screen I have select options and fetching is done at view2. Problem is we can pass parameter using inbound outbound parameters but how to pass internal table or field-symbols from one view to another view? I made use of Assistance Class too but its not very clear to me. Please give me some example or code to sort this problem out.
-
Its very urgent:how to insert data into database tables
Hi All,
I am very new to oaf.
I have one requirement data insert into database tables.
here createPG having data that data insert into one custom table.
but i dont know how to insert data into database tables.
i wrote the code in am,co as follows.
in am i wrote the code:
public void NewoperationManagerLogic()
ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
OADBTransaction oadbt=getOADBTransaction();
if(!vo1.isPreparedForExecution())
vo1.executeQuery();
Row row=vo1.createRow();
vo1.insertRow(row);
in createPG processrequest co:
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.NewoperationManagerLogic();
process form request:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Submit")!=null)
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.getOADBTransaction().commit();
please help with an example(sample code).
its very urgent.
thanks in advance
Seshu
Edited by: its urgent on Dec 25, 2011 9:31 PMHi ,
1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
Thanks
Pratap -
Hi Friends,
what is the meaning of 'I' in IND Val field ,which comes with some wagetypes only, in Basic pay infotype.
If 'I' is there in the field it is not storing the value in a table so there is a problem with the calculations for some developments.
how to restrict that 'I' in basic infotype ?if we restrict that will there be any effect in the other areas?
very urgent..appreciate any help..Hi Nandita
'I' means indirect evaluation of the amount for the wage type. So, if you enter any value, then the amount limit will be computed from using IT0008 or IT0052 and checked with the value entered and 'I' will be removed. If you do not enter any value, then the amount for this wagetype will be computed by SAP function module.
You can check the table T511 and for Wage type where MODNA is not initial are indirect wage types.
Thanks
Navneet -
How to keep Field symbol reference
HI ALL ,
I have method with that assign field symbol on it and I want to keep the reference of it ,
does it impossible ?
For instance
ASSIGN cs_structure TO <ls_structure>. "both are type any and are always structure with fields f1...fn
assign_request(
EXPORTING
is_fields = ls_fields
ev_out = es_field "F2
CHANGING
cs_str = <ls_structure>
es_field = '1'
Here I have method that in the method I always need to return field from the structure (es_field - I dont know how to define it
type any or type ref to data )
my question is assume in <ls_structure> I have field called F2 and I want to receive it but to keep the reference i.e.
if i do after the method call es_field = '1' the field F2 on structure <ls_structure> will contain '1'.
There is a way to do that ?
Regards
JoyHI Naimesh
I already try to define es_field as type ref to data but the issue is that for instance
field symbol <lv_field> type any.
ASSIGN cs_structure TO <ls_structure>.
inside the method assign_request I am doing ...
ASSIGN COMPONENT 'F2' OF STRUCTURE cs_str TO <lv_field>.
GET REFERENCE OF <lv_field> INTO ev_out.
call to the method
assign_request(
EXPORTING
is_fields = ls_fields
ev_out = es_field
CHANGING
cs_str = <ls_structure>
and after the method assign_request
ASSIGN es_field->* to <lv_field>.
<lv_field> = '1.'
Now I except that cs_structure and <ls_structure> that have field F2 you see that value '1' but its not working ,
what i miss here ?
Regards
joy -
Hi very urgent How to improve the performence of the program
Hi all please tell me how to improve the performence of this program......
REPORT z03_gil010 NO STANDARD PAGE HEADING LINE-SIZE 130.
INCLUDE *
INCLUDE: z00_bci010. " Gestion des anomalies.
Déclaration des données *
Tables de la bases de données *
TABLES:
ekpo, " Poste document d'achat.
lfa1, " Base fournisseurs (généralités).
marc, " Données division de l'article.
z03_bw_cmp1,
eord, "Répertoire des sources appro. Achats
eina, "Fiche infos-achats - données générales
t024, "Groupes d'acheteurs
tvarv. "FAE17345+
Déclaration des données internes *
Déclaration de la table interne qui permet de recuperer les mois.
DATA: BEGIN OF itb_months OCCURS 12.
INCLUDE STRUCTURE t247.
DATA: END OF itb_months.
Table pour récupération d'infos sur les divisions
DATA: BEGIN OF itb_t001w OCCURS 0,
werks LIKE t001w-werks,
fabkl LIKE t001w-fabkl," Clé du calendrier d'entreprise
END OF itb_t001w.
Déclaration de la table interne contenant les infos sur l'adresse du
fournisseur.
DATA: BEGIN OF itb_adresse OCCURS 0,
lifnr LIKE lfa1-lifnr, " Numéro de compte fournisseur.
name1 LIKE lfa1-name1, " Nom 1.
name2 LIKE lfa1-name2, " Nom 2.
name3 LIKE lfa1-name3, " Nom 3.
name4 LIKE lfa1-name4, " Nom 4.
stras LIKE lfa1-stras, " N° de rue et nom de la rue.
pstlz LIKE lfa1-pstlz, " Code postal.
ort01 LIKE lfa1-ort01, " Localité.
pfach LIKE lfa1-pfach, " Boîte postale.
pstl2 LIKE lfa1-pstl2, " Code de la boîte postale.
land1 LIKE lfa1-land1, " Clé de pays.
landx LIKE t005t-landx, " Pays.
spras LIKE lfa1-spras, " Code langue
END OF itb_adresse.
Déclaration d'une table interne pour les informations sur les
prévisions de commande.
DATA: BEGIN OF itb_prev_cde OCCURS 0,
werks LIKE marc-werks, " Division
idnlf LIKE eina-idnlf, " ADDsde ref article frn
lifnr LIKE eord-lifnr, " N° fournisseur.
ekgrp LIKE marc-ekgrp, " Groupe d'acheteurs
dispo LIKE marc-dispo, " Code gestionnaire MRP
matnr LIKE eord-matnr, " Article.
maktx LIKE makt-maktx, " Désignation article.
bstmi LIKE marc-bstmi, " Quantité de commande.
men00 LIKE plaf-gsmng, " Quantité du mois en cours M.
men01 LIKE plaf-gsmng, " Quantité pour le mois M+1.
men02 LIKE plaf-gsmng, " Quantité pour le mois M+2.
men03 LIKE plaf-gsmng, " Quantité pour le mois M+3.
men04 LIKE plaf-gsmng, " Quantité pour le mois M+4.
men05 LIKE plaf-gsmng, " Quantité pour le mois M+5.
men06 LIKE plaf-gsmng. " Quantité pour le mois M+6.
DATA: END OF itb_prev_cde.
Structure de travail pour les commandes convernant les PFC
DATA str_pca_pfc LIKE itb_prev_cde.
*add sde
DATA str_eord_pfc LIKE itb_prev_cde.
Structure de travail pour les prévisons PFC
DATA str_prev_pfc LIKE itb_prev_cde.
Déclaration d'une table interne pour les informations sur le
portefeuille des commandes d'achat.
DATA: BEGIN OF itb_pca OCCURS 0,
werks LIKE ekpo-werks, " Division
idnlf LIKE eina-idnlf, " ADDsde ref article frn
lifnr LIKE eord-lifnr, " N° fournisseur.
ekgrp LIKE marc-ekgrp, " Groupe d'acheteurs
dispo LIKE marc-dispo, " Code gestionnaire MRP
matnr LIKE eord-matnr, " Article.
maktx LIKE makt-maktx, " Désignation article.
ebeln LIKE ekes-ebeln, " Numéro du document d'achat.
ebelp LIKE ekes-ebelp, " Numéro de poste du document d'achat.
slfdt LIKE eket-slfdt, " Date de livraison statistique
eindt LIKE ekes-eindt, " Date de livraison indiquée dans la
" confirmation de la cde.
menge LIKE ekes-menge, " Quantité indiquée dans la confirma-
" tion de la commande.
attdu LIKE eket-wemng, " Portefeuille fournisseur.
netpr LIKE ekpo-brtwr, " Prix net du document d'achat dans
" la devise du document.
rtard TYPE i, " Retard en jours ouvres.
wemng LIKE eket-wemng, " Quantité de l'entrée de marchandise.
bldat LIKE mkpf-bldat, " Date inscrite sur la pièce/sur le
" document.
qtran LIKE ekes-menge, " Quantité en transit.
dtran LIKE ekes-eindt. " Date du dernier avis de transit.
DATA: END OF itb_pca.
DATA: w_i TYPE i, "Compteur
w_i_char(1) TYPE c, "Texte pour récupérer compteur
w_nm_zone(20) TYPE c, "Nom zone pour assign au field-symbols
w_nb_j TYPE i, "Nb de jours ouvrés jusqu'à fin mois
w_nb_j_tot TYPE i. "Nb de jours ouvrés du mois
FIELD-SYMBOLS: TYPE ANY.
Déclaration d'une table contenant les fiches info achat.
DATA: BEGIN OF itb_eina OCCURS 0,
matnr LIKE eina-matnr,
lifnr LIKE eina-lifnr,
idfnl LIKE eina-idnlf.
DATA: END OF itb_eina.
Déclaration d'une table contenant les infos groupe acheteur.
*DATA: BEGIN OF itb_t024 OCCURS 0,
ekgrp LIKE t024-ekgrp,
eknam LIKE t024-eknam,
ektel LIKE t024-ektel,
telfx LIKE t024-telfx.
*DATA: END OF itb_t024.
Déclaration d'une table pour le transfert du fichier.
DATA: BEGIN OF itb_transfert OCCURS 0,
col00(8), "division
col00bis(20), "Reference article
col01(18), "No article
col02(45), "libelle article
col021(17), "Groupe acheteur
col022(13), "gestionnaire
col03(17), "qte commandée ou No de commande
col04(13), "Mois 1 ou No poste cde
col05(20), "Mois 2 ou délai initial
col06(33), "Mois 3 ou délai négocié
col07(13), "Mois 4 ou qté cdée
col08(13), "Mois 5 ou qté attendue
col09(13), "Mois 6 ou Montant attendu
col10(13), "Mois 7 ou retard
col11(13), "qte partielle livree
col12(13), "date livraison partielle
col13(13), "qté en transit
col14(13). "date
DATA: END OF itb_transfert.
Déclaration d'une table contenant la liste des fournisseurs.
DATA: BEGIN OF itb_lifnr OCCURS 0,
werks LIKE marc-werks,
idfnl LIKE eina-idnlf,
lifnr LIKE eord-lifnr,
ekgrp LIKE marc-ekgrp,
spras LIKE lfa1-spras,
eknam LIKE t024-eknam,
ektel LIKE t024-ektel,
telfx LIKE t024-telfx.
DATA: END OF itb_lifnr.
Déclaration d'une structure pour la selection dans la table MSEG.
DATA : BEGIN OF itb_mseg OCCURS 0,
mblnr LIKE mseg-mblnr,
mjahr LIKE mseg-mjahr,
ebeln LIKE mseg-ebeln,
ebelp LIKE mseg-ebelp,
END OF itb_mseg.
déclaration d'une structure pour la selection dans EKPO.
DATA : BEGIN OF itb_ekpo OCCURS 0,
lifnr LIKE ekko-lifnr,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
menge LIKE ekpo-menge,
bpumz LIKE ekpo-bpumz,
bpumn LIKE ekpo-bpumn,
matnr LIKE ekpo-matnr,
werks LIKE ekpo-werks,
netpr LIKE ekpo-netpr,
peinh LIKE ekpo-peinh, "Base de prix FAE17345+
ekgrp LIKE ekko-ekgrp, "AFT++
dispo LIKE marc-dispo, "AFT++
END OF itb_ekpo.
déclaration d'une structure pour la selection dans EKPO.
DATA : BEGIN OF itb_ekko OCCURS 0,
ebeln LIKE ekko-ebeln,
lifnr LIKE ekko-lifnr,
spras LIKE ekko-spras,
END OF itb_ekko.
déclaration d'une structure pour la selection dans EKES.
DATA : BEGIN OF itb_ekes OCCURS 0,
ebeln LIKE eket-ebeln,
ebelp LIKE eket-ebelp,
ebtyp LIKE ekes-ebtyp,
eindt LIKE ekes-eindt,
menge LIKE ekes-menge,
dabmg LIKE ekes-dabmg,
etens LIKE ekes-etens,
END OF itb_ekes.
déclaration d'une structure pour la selection dans EKET
DATA : BEGIN OF itb_eket OCCURS 0,
ebeln LIKE eket-ebeln,
ebelp LIKE eket-ebelp,
menge LIKE eket-menge,
wemng LIKE eket-wemng,
eindt LIKE eket-eindt,
slfdt LIKE eket-slfdt,
END OF itb_eket.
déclaration d'une structure pour la selection dans MKPF.
DATA : BEGIN OF itb_mkpf OCCURS 0,
mblnr LIKE mkpf-mblnr,
mjahr LIKE mkpf-mjahr,
bldat LIKE mkpf-bldat,
END OF itb_mkpf.
Déclaration d'une structure pour la sélection dans EORD.
DATA : BEGIN OF itb_eord OCCURS 0,
matnr LIKE eord-matnr,
werks LIKE eord-werks,
lifnr LIKE eord-lifnr,
ekgrp LIKE marc-ekgrp,
dispo LIKE marc-dispo, "DE3K924352
disls LIKE marc-disls,
bstfe LIKE marc-bstfe,
bstrf LIKE marc-bstrf,
bstmi LIKE marc-bstmi,
bstma LIKE marc-bstma,
END OF itb_eord.
DATA : BEGIN OF itb_eordw OCCURS 0.
INCLUDE STRUCTURE itb_eord.
DATA : END OF itb_eordw.
Déclaration d'une structure pour la sélection dans MAKT.
DATA : BEGIN OF itb_makt OCCURS 0,
matnr LIKE makt-matnr,
spras LIKE makt-spras,
maktx LIKE makt-maktx,
END OF itb_makt.
Déclaration d'une structure pour la sélection dans EBAN.
DATA : BEGIN OF itb_eban OCCURS 0,
matnr LIKE eban-matnr,
werks LIKE eban-werks,
flief LIKE eban-flief,
lfdat LIKE eban-lfdat,
menge LIKE eban-menge,
bsmng LIKE eban-bsmng,
webaz LIKE eban-webaz,
ekgrp LIKE eban-ekgrp,
ebeln LIKE eban-ebeln,
banfn LIKE eban-banfn,
bnfpo LIKE eban-bnfpo, "DB3K900702+
END OF itb_eban.
Déclaration d'une structure pour la sélection dans PLAF.
DATA : BEGIN OF itb_plaf OCCURS 0,
plnum LIKE plaf-plnum, "DB3K900702+
matnr LIKE plaf-matnr,
plwrk LIKE plaf-plwrk,
flief LIKE plaf-flief,
pedtr LIKE plaf-pedtr,
gsmng LIKE plaf-gsmng,
webaz LIKE plaf-webaz,
END OF itb_plaf.
Déclaration d'une structure pour la sélection dans MARC.
DATA : BEGIN OF itb_marc OCCURS 0,
matnr LIKE marc-matnr,
werks LIKE marc-werks,
disls LIKE marc-disls,
bstrf LIKE marc-bstrf,
bstmi LIKE marc-bstmi,
bstma LIKE marc-bstma,
bstfe LIKE marc-bstfe,
ekgrp LIKE marc-ekgrp,
dispo LIKE marc-dispo,
END OF itb_marc.
DATA : BEGIN OF itb_marc_eord OCCURS 0,
matnr LIKE marc-matnr,
werks LIKE marc-werks,
strgr LIKE marc-strgr, "groupe de stratégie planif
END OF itb_marc_eord.
DATA : BEGIN OF itb_z03_bw_cmp1 OCCURS 0,
matnr LIKE z03_bw_cmp1-matnr,
werks LIKE z03_bw_cmp1-werks,
pdatu LIKE z03_bw_cmp1-pdatu,
plnmg LIKE z03_bw_cmp1-plnmg,
END OF itb_z03_bw_cmp1.
Begin change BNI <DE3K937051>
DATA : BEGIN OF itb_z03_bw_cmp2 OCCURS 0,
matnr LIKE z03_bw_cmp2-matnr,
werks LIKE z03_bw_cmp2-werks,
pdatu LIKE z03_bw_cmp2-pdatu,
plnmg LIKE z03_bw_cmp2-plnmg,
END OF itb_z03_bw_cmp2.
*End change BNI
DATA : BEGIN OF str_index1,
matnr LIKE eord-matnr,
werks LIKE eord-werks,
END OF str_index1.
DATA : BEGIN OF str_index2,
matnr LIKE eord-matnr,
werks LIKE eord-werks,
END OF str_index2.
DATA : BEGIN OF str_index3_eord,
matnr LIKE eord-matnr,
werks LIKE eord-werks,
END OF str_index3_eord.
DATA : BEGIN OF str_index4,
matnr LIKE eord-matnr,
werks LIKE eord-werks,
END OF str_index4.
DATA : BEGIN OF str_index5,
matnr LIKE eord-matnr,
werks LIKE eord-werks,
END OF str_index5.
DATA : BEGIN OF str_index6,
matnr LIKE eord-matnr,
werks LIKE eord-werks,
END OF str_index6.
DATA : BEGIN OF str_index7,
matnr LIKE eord-matnr,
werks LIKE eord-werks,
END OF str_index7.
Déclaration des variables de debut et de fin de mois.
DATA: w_debut_mois LIKE sy-datum,
w_debut_periode LIKE sy-datum,
w_fin_mois LIKE sy-datum,
w_fin_periode LIKE sy-datum.
Déclaration des variables pour les dates.
DATA: w_date0 LIKE sy-datum,
w_date1 LIKE sy-datum,
w_date2 LIKE sy-datum,
w_date3 LIKE sy-datum,
w_date4 LIKE sy-datum,
w_date5 LIKE sy-datum,
w_date6 LIKE sy-datum,
w_datejour LIKE sy-datum, "FAE15269
w_dat_da LIKE eban-lfdat,
w_dat_op LIKE plaf-pedtr,
w_mois0 LIKE t247-ltx,
w_mois1 LIKE t247-ltx,
w_mois2 LIKE t247-ltx,
w_mois3 LIKE t247-ltx,
w_mois4 LIKE t247-ltx,
w_mois5 LIKE t247-ltx,
w_mois6 LIKE t247-ltx,
w_lendemain LIKE sy-datum. "FAE17345+
Temoin d'un AR dans la commande d'achat.
DATA: w_temoin_ar.
Numéro de la confirmation de la commande
DATA : w_etens LIKE ekes-etens.
Déclaration des variables pour le nom des fichiers.
DATA: w_nom_fichier LIKE rlgrap-filename,
w_fichier LIKE rlgrap-filename,
w_racine LIKE rlgrap-filename,
w_file LIKE rlgrap-filename.
Déclaration d'une table interne pour le transfert.
DATA: BEGIN OF itb_trans OCCURS 0,
w_ligne(320).
DATA: END OF itb_trans.
Déclaration d'une variable pour rechercher les enregistrements vides.
DATA: w_compteur TYPE i,
w_compteur1 TYPE i,
w_compteur2 TYPE i,
w_retard TYPE i, " Retard en jours ouvres.
w_trouve_pfc TYPE c, "addsde
w_trouve_pfs TYPE c, "+DE3K937051
w_trouve TYPE c.
*Index pour les LOOP
DATA : w_index_ekpo LIKE sy-tabix,
w_index_ekes LIKE sy-tabix,
w_index_eket LIKE sy-tabix,
w_index_mseg LIKE sy-tabix,
w_index_eban LIKE sy-tabix,
w_index_plaf LIKE sy-tabix,
w_index_pca LIKE sy-tabix,
w_index_z03_bw_cmp1 LIKE sy-tabix,
w_index_z03_bw_cmp2 LIKE sy-tabix."+DE3K937051
RANGES : r_type_pfs FOR marc-strgr.
*fichier sur serveur +EDR231003
DATA : w_chemin LIKE filename-fileintern, "nom du fichier
w_date_fichier(12) TYPE c, "Date format DD_MM_AA
w_csv(307) TYPE c. "ligne du fichier format CSV
CONSTANTS: k_imputation_m LIKE eban-knttp VALUE 'M'. "FAE19001+
Description de l écran de sélection *
Paramètres "UTILISATION" *
Ouverture d'un block de sélection pour le(s) fournisseur(s).
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-bl1.
Sélection division(s)
SELECT-OPTIONS: s_werks FOR ekpo-werks.
Sélection fournisseur(s).
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr OBLIGATORY.
Sélection du Groupe d'acheteur
*SELECT-OPTIONS: s_ekgrp FOR marc-ekgrp. "-FAE26446
*SELECT-OPTIONS: s_dispo FOR marc-dispo. "-FAE26446
SELECTION-SCREEN END OF BLOCK block1.
FAE 26446 : ajout
SELECTION-SCREEN BEGIN OF BLOCK block3 WITH FRAME TITLE text-bl3.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_ekgrp RADIOBUTTON GROUP g3.
SELECTION-SCREEN COMMENT 5(24) text-001 FOR FIELD p_ekgrp.
SELECT-OPTIONS: s_ekgrp FOR marc-ekgrp.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETER p_dispo RADIOBUTTON GROUP g3.
SELECTION-SCREEN COMMENT 5(24) text-002 FOR FIELD p_dispo.
SELECT-OPTIONS: s_dispo FOR marc-dispo.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK block3.
FAE 26446 : fin ajout
Paramètres "SYSTEME" *
Saut de 2 lignes.
SELECTION-SCREEN: SKIP 2.
Ouverture d'un block de sélection pour l'adresse physique du fichier.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-bl2.
PARAMETERS: p_pc RADIOBUTTON GROUP rad1 DEFAULT 'X', "+EDR231003
p_fic_pc LIKE rlgrap-filename. "+EDR231003
SELECTION-SCREEN SKIP. "+EDR231003
PARAMETERS : p_serve RADIOBUTTON GROUP rad1, "+EDR231003
p_fic_se LIKE filename-fileintern "+EDR231003
DEFAULT 'Z03_PREV_COMMANDES'. "+EDR231003
SELECTION-SCREEN END OF BLOCK block2.
Logique de traitement *
INITIALIZATION *
INITIALIZATION.
Date du jour
MOVE sy-datum TO w_datejour. "FAE15269
Gestion des anomalies.
MOVE text-lb1 TO w_lb_traitement.
PERFORM f930_init USING sy-cprog '30'.
Fin de la gestions des anomalies.
Récuperation des mois dans la table interne 'ITB_MONTHS'.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
language = sy-langu
TABLES
month_names = itb_months
EXCEPTIONS
month_names_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Récupération des differentes periodes.
PERFORM f100_recuperation_date TABLES itb_months.
Récupération du debut du mois.
CONCATENATE sy-datlo(6) '01' INTO w_debut_mois.
MOVE: w_debut_mois TO w_debut_periode.
Récupération du dernier jour du mois.
CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
day_in = sy-datlo
IMPORTING
last_day_of_month = w_fin_mois
EXCEPTIONS
day_in_no_date = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
TOP-OF-PAGE *
TOP-OF-PAGE.
CALL FUNCTION 'Z_00_BC_TOP_OF_PAGE'
EXPORTING
p_linsz = k_ligne
p_pagno = sy-pagno
p_prog = sy-cprog
p_projet = k_projet
p_societe = k_societe
p_sujet = sy-title.
END-OF-PAGE *
END-OF-PAGE.
AT SELECTION-SCREEN *
FAE 26446 : ajout
AT SELECTION-SCREEN ON BLOCK block3.
IF NOT ( s_ekgrp IS INITIAL )
AND NOT ( s_dispo IS INITIAL ).
MESSAGE e394(z03_mm).
ENDIF.
IF p_ekgrp = 'X'.
IF s_ekgrp IS INITIAL.
MESSAGE e395(z03_mm).
ENDIF.
ELSE.
IF s_dispo IS INITIAL.
MESSAGE e396(z03_mm).
ENDIF.
ENDIF.
fae26446 fin ajout
AT SELECTION-SCREEN ON BLOCK block2.
IF p_pc = 'X'.
IF p_fic_pc IS INITIAL.
*Attention, il n'y a aucune adresse de sauvegarde pour le(s) fichier(s)
MESSAGE e021(z03_mm).
ENDIF.
ELSE.
IF p_fic_se IS INITIAL.
*Attention, il n'y a aucune adresse de sauvegarde pour le(s) fichier(s)
MESSAGE e021(z03_mm).
ENDIF.
ENDIF.
Création du matchcode pour la selection du fichier local.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fic_pc.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = p_fic_pc
def_path = 'C:'
mask = text-ma1
mode = 'S'
title = text-sel
IMPORTING
filename = p_fic_pc
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc NE 0 AND sy-subrc NE 3.
MESSAGE e032(z03_mm).
ENDIF.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM select_donnees.
=================================================
Liste des ARTICLES impactés pour les prévisions *
=================================================
===================================
PORTEFEUILLE DE COMMANDES D'ACHAT *
===================================
Construction itb_pca à partir de EKKO/EKPO.
w_index_ekpo = 1.
w_index_ekes = 1.
w_index_eket = 1.
w_index_mseg = 1.
SORT itb_ekko BY ebeln. "-FAE26446
SORT itb_ekpo BY ebeln ebelp.
SORT itb_makt BY matnr spras.
SORT itb_eket BY ebeln ebelp.
SORT itb_ekes BY ebeln ebelp.
SORT itb_mseg BY ebeln ebelp.
SORT itb_mkpf BY mblnr mjahr.
SORT itb_marc BY matnr werks. "+FAE26446
FAE 26446 remplacement
LOOP AT itb_ekko.
LOOP AT itb_ekpo.
FROM w_index_ekpo.
IF itb_ekko-ebeln = itb_ekpo-ebeln.
LOOP AT itb_ekpo.
READ TABLE itb_marc WITH KEY
matnr = itb_ekpo-matnr
werks = itb_ekpo-werks BINARY SEARCH.
CHECK sy-subrc = 0.
FAE 26446 fin remplacement
itb_pca-ebeln = itb_ekpo-ebeln.
itb_pca-ebelp = itb_ekpo-ebelp.
itb_pca-lifnr = itb_ekko-lifnr. "-FAE26446
itb_pca-lifnr = itb_ekpo-lifnr. "+FAE26446
itb_pca-ekgrp = itb_ekpo-ekgrp. "+FAE26446
itb_pca-dispo = itb_ekpo-dispo. "+FAE26446
itb_pca-matnr = itb_ekpo-matnr.
itb_pca-werks = itb_ekpo-werks.
Recherche du libellé article
READ TABLE itb_makt
WITH KEY matnr = itb_ekpo-matnr
spras = text-fra
BINARY SEARCH.
IF sy-subrc = 0.
itb_pca-maktx = itb_makt-maktx.
ELSE.
READ TABLE itb_makt
WITH KEY matnr = itb_ekpo-matnr
spras = text-ang
BINARY SEARCH.
IF sy-subrc = 0.
itb_pca-maktx = itb_makt-maktx.
ENDIF.
ENDIF.
IF NOT itb_ekpo-bpumn IS INITIAL.
itb_pca-menge = itb_ekpo-menge * itb_ekpo-bpumz /
itb_ekpo-bpumn.
ENDIF.
Sélect° ds la table EKES des dates de livraisons et des qtés
en transit
CLEAR w_temoin_ar.
CLEAR w_etens.
LOOP AT itb_ekes
FROM w_index_ekes.
IF itb_ekes-ebeln = itb_ekpo-ebeln
AND itb_ekes-ebelp = itb_ekpo-ebelp.
IF itb_ekes-ebtyp = text-arn.
itb_pca-eindt = itb_ekes-eindt.
w_temoin_ar = 'X'.
ELSE.
Si c'est une qté en transit alors on recupere
la quantité et la date.
IF itb_ekes-dabmg < itb_ekes-menge.
itb_pca-qtran = itb_pca-qtran + itb_ekes-menge -
itb_ekes-dabmg.
ENDIF.
IF itb_ekes-etens > w_etens.
w_etens = itb_ekes-etens.
itb_pca-dtran = itb_ekes-eindt.
ENDIF.
ENDIF.
ELSEIF itb_ekes-ebeln > itb_ekpo-ebeln
OR ( itb_ekes-ebeln = itb_ekpo-ebeln
AND itb_ekes-ebelp > itb_ekpo-ebelp ).
w_index_ekes = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
S'il n'y a pas d'AR alors récupérat° de la date livraison dans EKET.
LOOP AT itb_eket
FROM w_index_eket.
IF itb_eket-ebeln = itb_ekpo-ebeln
AND itb_eket-ebelp = itb_ekpo-ebelp.
IF w_temoin_ar IS INITIAL.
itb_pca-eindt = itb_eket-eindt.
ENDIF.
itb_pca-slfdt = itb_eket-slfdt.
Calcul du portefeuille fournisseur à partir de la
qté commandée et la qté reçue
itb_pca-attdu = itb_pca-attdu + itb_eket-menge -
itb_eket-wemng.
Calcul du montant du poste
itb_pca-netpr = itb_ekpo-netpr * itb_pca-attdu.
IF itb_ekpo-peinh NE 0.
itb_pca-netpr = itb_pca-netpr / itb_ekpo-peinh.
ENDIF.
Calcul quantité réceptionnée.
itb_pca-wemng = itb_pca-wemng + itb_eket-wemng.
Calcul du retard en nombre de jours calendaires
Le calcul du retard ne doit pas prendre en compte
le jour de livraison
ADD 1 TO itb_eket-eindt.
IF NOT itb_pca-attdu IS INITIAL
AND itb_eket-eindt LT sy-datum.
Calcul du retard en nombre de jours ouvrés
CLEAR w_retard.
CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_PERIOD'
EXPORTING
date_deb = itb_eket-eindt
date_fin = sy-datum
IMPORTING
jours = w_retard.
itb_pca-rtard = itb_pca-rtard + w_retard .
ENDIF.
ELSEIF itb_eket-ebeln > itb_ekpo-ebeln
OR ( itb_eket-ebeln = itb_ekpo-ebeln
AND itb_eket-ebelp > itb_ekpo-ebelp ).
w_index_eket = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
Recherche de la derniere date de livraison.
LOOP AT itb_mseg
FROM w_index_mseg.
IF itb_mseg-ebeln = itb_ekpo-ebeln
AND itb_mseg-ebelp = itb_ekpo-ebelp.
READ TABLE itb_mkpf
WITH KEY mblnr = itb_mseg-mblnr
mjahr = itb_mseg-mjahr
BINARY SEARCH.
IF sy-subrc = 0.
IF itb_mkpf-bldat > itb_pca-bldat.
itb_pca-bldat = itb_mkpf-bldat.
ENDIF.
ENDIF.
ELSEIF itb_mseg-ebeln > itb_ekpo-ebeln
OR ( itb_mseg-ebeln = itb_ekpo-ebeln
AND itb_mseg-ebelp > itb_ekpo-ebelp ).
w_index_mseg = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
APPEND itb_pca.
CLEAR itb_pca.
FAE26446 suppression parag. suivant
ELSEIF itb_ekpo-ebeln > itb_ekko-ebeln.
w_index_ekpo = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
Fin FAE26446
ENDLOOP.
=========================
PREVISIONS DE COMMANDES *
=========================
SORT itb_eord BY matnr werks lifnr ekgrp.
SORT itb_eban BY matnr werks flief ekgrp.
SORT itb_plaf BY matnr plwrk flief.
SORT itb_z03_bw_cmp1 BY matnr werks.
SORT itb_z03_bw_cmp2 BY matnr werks."+DE3K937051
SORT itb_pca BY matnr werks lifnr.
w_index_eban = 1.
w_index_plaf = 1.
w_index_z03_bw_cmp1 = 1.
w_index_pca = 1.
w_index_z03_bw_cmp2 = 1."+DE3K937051
Remplissage de la table des prévisions de commande.
LOOP AT itb_eord.
CLEAR: str_prev_pfc,
w_trouve.
MOVE-CORRESPONDING itb_eord TO str_index1.
MOVE-CORRESPONDING itb_eord TO str_index3_eord.
MOVE-CORRESPONDING itb_eord TO itb_prev_cde.
Recherche dans table division/article (MARC) afin de déterminer si
article PFS (prod fabriqué à stock) ou PFC (Prod fabriqué sur cde)
AT NEW werks.
READ TABLE itb_marc_eord
WITH KEY matnr = itb_eord-matnr
werks = itb_eord-werks
BINARY SEARCH.
IF sy-subrc NE 0.
CLEAR itb_marc_eord.
ENDIF.
ENDAT.
a - Prévisions pour les PFS : DA + OP *
*Calcul des quantités de commande.
IF itb_eord-disls = text-tl1.
itb_prev_cde-bstmi = itb_eord-bstfe.
ELSEIF itb_eord-disls = text-tl2
OR itb_eord-disls = text-tl3.
IF itb_eord-bstrf NE 0
AND itb_eord-bstmi = 0
AND itb_eord-bstma = 0.
itb_prev_cde-bstmi = itb_eord-bstrf.
ELSEIF itb_eord-bstrf NE 0
AND itb_eord-bstmi NE 0.
itb_prev_cde-bstmi = itb_eord-bstmi.
ELSEIF itb_eord-bstrf = itb_eord-bstma
AND itb_eord-bstrf NE 0
AND itb_eord-bstmi = 0.
itb_prev_cde-bstmi = itb_eord-bstma.
ENDIF.
ENDIF.
si article PFS (Prod fabriqué à stock) recherche des
demandes d'achat ou ordres planfiés
IF itb_marc_eord-strgr IN r_type_pfs.
Récupérat° calendrier de la division pour calcul correct lors de
l'ajout de eban-webaz ou plaf-webaz jours ouvrés
CLEAR w_trouve_pfs ."+DE3K937051
READ TABLE itb_t001w
WITH KEY werks = itb_eord-werks
BINARY SEARCH.
IF sy-subrc = 0.
LOOP AT itb_eban
FROM w_index_eban.
MOVE-CORRESPONDING itb_eban TO str_index2.
IF str_index1 = str_index2.
w_trouve_pfs = 'X'."+DE3K937051
si qte commandées pour la DA < quantité de la DA
IF itb_eban-bsmng < itb_eban-menge.
ajout de quantité de la DA - qte commandée pour la DA
PERFORM affect_da.
ENDIF.
ELSEIF str_index2 > str_index1.
w_index_eban = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ajout des quantité des OP (ordres planifiés)
LOOP AT itb_plaf
FROM w_index_plaf.
MOVE-CORRESPONDING itb_plaf TO str_index4.
str_index4-werks = itb_plaf-plwrk.
str_index4-lifnr = itb_plaf-flief.
IF str_index4 = str_index3_eord.
Ajout de webaz jours ouvrés à pedtr
CALL FUNCTION 'Z_03_MM_ADD_TO_FACTORYDATE'
EXPORTING
i_date = itb_plaf-pedtr
i_calendar_id = itb_t001w-fabkl
i_nb_days = itb_plaf-webaz
IMPORTING
o_date = w_dat_op
EXCEPTIONS
conv_error = 1
OTHERS = 2.
IF sy-subrc
If forecasts found in Z03_BW_CMP2 for the article
IF w_trouve_pfs = 'X'."-DE3K937602
Recalculation prev month M in fct of Nb of wrought days of the month
IF NOT itb_prev_cde-men00 IS INITIAL.
one does not hold any more account of the day in progress
w_lendemain = w_date0 + 1.
CLEAR:w_nb_j,w_nb_j_tot. "DE3K938206+
CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_PERIOD'
EXPORTING
date_deb = w_lendemain
date_fin = w_fin_mois
IMPORTING
jours = w_nb_j.
CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_MONTH'
EXPORTING
date = w_lendemain
IMPORTING
jours = w_nb_j_tot.
itb_prev_cde-men00 = itb_prev_cde-men00 * w_nb_j / w_nb_j_tot
*CLA DE3K925301 FAE27197
*to round has the higher entirety
itb_prev_cde-men00 = ceil( itb_prev_cde-men00 ). "DE3K938206-
ENDIF.
ENDIF."-DE3K937602
*End change BNI
b - Prévisions pour les PFC (Z03_BW_CMP1 puis rééquilibrage) *
Recherche des previsions dans Z03_BW_CMP1
si article PFC (Prod fabriqué sur cde) recherche des prévisions
IF NOT itb_marc_eord-strgr IN r_type_pfs.
CLEAR str_prev_pfc.
MOVE-CORRESPONDING itb_eord TO str_prev_pfc.
CLEAR w_trouve_pfc .
LOOP AT itb_z03_bw_cmp1
FROM w_index_z03_bw_cmp1.
MOVE-CORRESPONDING itb_z03_bw_cmp1 TO str_index7.
MOVE-CORRESPONDING itb_eord TO str_index6.
IF str_index6 = str_index7.
si on trouve des prévisions dans z03_bw_cmp1 pour la source
d'appro eord alors c'est un article PFC
w_trouve_pfc = 'X'.
CASE itb_z03_bw_cmp1-pdatu+0(6).
WHEN w_date0+0(6).
str_prev_pfc-men00 = itb_z03_bw_cmp1-plnmg.
WHEN w_date1+0(6).
str_prev_pfc-men01 = itb_z03_bw_cmp1-plnmg.
WHEN w_date2+0(6).
str_prev_pfc-men02 = itb_z03_bw_cmp1-plnmg.
WHEN w_date3+0(6).
str_prev_pfc-men03 = itb_z03_bw_cmp1-plnmg.
WHEN w_date4+0(6).
str_prev_pfc-men04 = itb_z03_bw_cmp1-plnmg.
WHEN w_date5+0(6).
str_prev_pfc-men05 = itb_z03_bw_cmp1-plnmg.
WHEN w_date6+0(6).
str_prev_pfc-men06 = itb_z03_bw_cmp1-plnmg.
WHEN OTHERS.
ENDCASE.
ELSEIF str_index7 > str_index6.
w_index_z03_bw_cmp1 = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
*Begin change BNI
Si des prévisions trouvées dans Z03_BW_CMP1 pour l'article
IF w_trouve_pfc = 'X'.
Recalcul prev mois M en fct du nb de jours ouvrés du mois
IF NOT str_prev_pfc-men00 IS INITIAL.
on ne tient plus compte du jour en cours
w_lendemain = w_date0 + 1.
CLEAR:w_nb_j,w_nb_j_tot. "DE3K938206+
CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_PERIOD'
EXPORTING
date_deb = w_lendemain
date_fin = w_fin_mois
IMPORTING
jours = w_nb_j.
CALL FUNCTION 'Z_00_BC_WORKDAYS_PER_MONTH'
EXPORTING
date = w_lendemain
IMPORTING
jours = w_nb_j_tot.
str_prev_pfc-men00 = str_prev_pfc-men00 * w_nb_j / w_nb_j_tot.
*CLA DE3K925301 FAE27197
*arrondir a l'entier supèrieur
str_prev_pfc-men00 = ceil( str_prev_pfc-men00 ).
ENDIF.
Equilibrage PFC : commande/prévision du mois
Recherche COMMANDES cumulées pour M à M+6
CLEAR str_pca_pfc.
LOOP AT itb_pca
FROM w_index_pca.
MOVE-CORRESPONDING itb_pca TO str_index5.
IF str_index5 = str_index3_eord.
IF NOT itb_pca-menge IS INITIAL.
CASE itb_pca-eindt+0(6).
WHEN w_date0+0(6).
IF itb_pca-eindt >= w_date0.
str_pca_pfc-men00 = str_pca_pfc-men00 + itb_pca-menge.
ENDIF.
WHEN w_date1+0(6).
str_pca_pfc-men01 = str_pca_pfc-men01 + itb_pca-menge.
WHEN w_date2+0(6).
str_pca_pfc-men02 = str_pca_pfc-men02 + itb_pca-menge.
WHEN w_date3+0(6).
str_pca_pfc-men03 = str_pca_pfc-men03 + itb_pca-menge.
WHEN w_date4+0(6).
str_pca_pfc-men04 = str_pca_pfc-men04 + itb_pca-menge.
WHEN w_date5+0(6).
str_pca_pfc-men05 = str_pca_pfc-men05 + itb_pca-menge.
WHEN w_date6+0(6).
str_pca_pfc-men06 = str_pca_pfc-men06 + itb_pca-menge.
ENDCASE.
ENDIF."NOT itb_pca-menge IS INITIAL
ELSEIF str_index5 > str_index3_eord.
w_index_pca = sy-tabix.
EXIT.
ENDIF.
ENDLOOP."itb_pca
*. Equilibrer commande / prévision des mois : diminuer la quantité de
prévision de chaque mois par le portefeuille de commande client du
mois*. Si ce solde est négatif alors lui donner la valeur 0.
w_i = 0.
Ajustement commandes/prévisions pour les mois M à M+6
WHILE w_i .
Pour un mois, SI Prévisions > Commandes en cours
IF .
Prévisions = Prévisions - Commandes en cours
= 0.
ENDIF.
On passe au mois suivant
w_i = w_i + 1.
ENDWHILE.
MOVE str_prev_pfc-men00 TO itb_prev_cde-men00.
MOVE str_prev_pfc-men01 TO itb_prev_cde-men01.
MOVE str_prev_pfc-men02 TO itb_prev_cde-men02.
MOVE str_prev_pfc-men03 TO itb_prev_cde-men03.
MOVE str_prev_pfc-men04 TO itb_prev_cde-men04.
MOVE str_prev_pfc-men05 TO itb_prev_cde-men05.
MOVE str_prev_pfc-men06 TO itb_prev_cde-men06.
Hi
You check in SM50 by executing the programing, You will come to know which select is taking more time and accordingly you modify that select.
You can do SQL trace and Run time analysis and analyse and see.
check this and use
1) Dont use nested select statements
2) If possible use for all entries in addition
3) In the where addition make sure you give all the primary key
4) Use Index for the selection criteria.
5) You can also use inner joins
6) You can try to put the data from the first select statement into an Itab and then in order to select the data from the second table use for all entries in.
7) Use the runtime analysis SE30 and SQL Trace (ST05) to identify the performance and also to identify where the load is heavy, so that you can change the code accordingly
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5d0db4c9-0e01-0010-b68f-9b1408d5f234
ABAP performance depends upon various factors and in devicded in three parts:
1. Database
2. ABAP
3. System
Run Any program using SE30 (performance analys) to improve performance refer to tips and trics section of SE30, Always remember that ABAP perfirmance is improved when there is least load on Database.
u can get an interactive grap in SE30 regarding this with a file.
also if u find runtime of parts of codes then use :
Switch on RTA Dynamically within ABAP Code
*To turn runtim analysis on within ABAP code insert the following code
SET RUN TIME ANALYZER ON.
*To turn runtim analysis off within ABAP code insert the following code
SET RUN TIME ANALYZER OFF.
Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
Avoid for all entries in JOINS
Try to avoid joins and use FOR ALL ENTRIES.
Try to restrict the joins to 1 level only ie only for tables
Avoid using Select *.
Avoid having multiple Selects from the same table in the same object.
Try to minimize the number of variables to save memory.
The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
Avoid creation of index as far as possible
Avoid operators like <>, > , < & like % in where clause conditions
Avoid select/select single statements in loops.
Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
Avoid using ORDER BY in selects
Avoid Nested Selects
Avoid Nested Loops of Internal Tables
Try to use FIELD SYMBOLS.
Try to avoid into Corresponding Fields of
Avoid using Select Distinct, Use DELETE ADJACENT
Check the following Links
Re: performance tuning
Re: Performance tuning of program
http://www.sapgenie.com/abap/performance.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
check the below link
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
See the following link if it's any help:
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
Check also http://service.sap.com/performance
and
books like
http://www.sap-press.com/product.cfm?account=&product=H951
http://www.sap-press.com/product.cfm?account=&product=H973
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
Performance tuning for Data Selection Statement
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
Debugger
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
http://www.cba.nau.edu/haney-j/CIS497/Assignments/Debugging.doc
http://help.sap.com/saphelp_erp2005/helpdata/en/b3/d322540c3beb4ba53795784eebb680/frameset.htm
Run Time Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
SQL trace
http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
CATT - Computer Aided Testing Too
http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
Test Workbench
http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
Coverage Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
Runtime Monitor
http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
Memory Inspector
http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
ECATT - Extended Computer Aided testing tool.
http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
Just refer to these links...
performance
Performance
Performance Guide
performance issues...
Performance Tuning
Performance issues
performance tuning
performance tuning
You can go to the transaction SE30 to have the runtime analysis of your program.Also try the transaction SCI , which is SAP Code Inspector.
1 Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
2 Avoid for all entries in JOINS
3 Try to avoid joins and use FOR ALL ENTRIES.
4 Try to restrict the joins to 1 level only ie only for 2 tables
5 Avoid using Select *.
6 Avoid having multiple Selects from the same table in the same object.
7 Try to minimize the number of variables to save memory.
8 The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
9 Avoid creation of index as far as possible
10 Avoid operators like <>, > , < & like % in where clause conditions
11 Avoid select/select single statements in loops.
12 Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
13 Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
14 Avoid using ORDER BY in selects
15 Avoid Nested Selects
16 Avoid Nested Loops of Internal Tables
17 Try to use FIELD SYMBOLS.
18 Try to avoid into Corresponding Fields of
19 Avoid using Select Distinct, Use DELETE ADJACENT.
Regards
Anji -
How to handle field symbols internal table values?
HI all,
I declared field string as below.The below code is working fine.
Data : ITAB TYPE STANDARD TABLE OF YAPOPLN, (Custom table).
wa_itab like line of ITAB.
field-symbol : <fs> type ITAB.
ASSIGN PARAM TO <FS>
LOOP AT <FS> INTO WA_ITAB.
WRITE:/ 'ABC'.
ENDLOOP.
But my requirement is that I dont want all the fields of the table YAPOPLN.My output contains only 2 fields of the table YAPOPLN,which contains total 4 fields.According to my requirement only 2 fields will be getting into one parameter PARAM(this is function module parameter,which is from ALV classes) from the user entered output,which contains only 2 fields.So the above code is not working properly because wa_itab contains 4 fields and giving short dump.
If I am declaring the internal table with the required fields(only 2 fields) and referring that internal table to field symbol <FS>
Data : BEGIN OF ITAB1 OCCURS 0,
FIELD1 LIKE YAPOPLN-FIELD1,
FIELD2 LIKE YAPOPLN-FIELD2,
END OF ITAB1.
field-symbol : <fs> LIKE ITAB1 OR <FS> TYPE ANY.
DATA :WA_ITAB1 LIKE LINE OF ITAB1.
ASSIGN PARAM TO <FS>
LOOP AT <FS> INTO WA_ITAB.
WRITE:/ 'ABC'.
ENDLOOP.
But when I am compiling this code i am getting the below error.I am gettting the same below error when even <FS> is also declared as <FS> TYPE ANY.
.'FS' is not an internal table or defined in TABLES.
Can anyone help me in this regard?
Thanks,
BalajiHello,
Try this way:
If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
itab = <itab>.
Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
Now, you can create <wa> as follow:
FIELD-SYMBOLS <wa>.
DATA wa TYPE REF TO DATA.
CREATE DATA wa TYPE LINE OF <itab>.
ASSIGN wa->* to <wa>.
This way your work area is read.
Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
Finally you can use that value to load static internal table.
You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
Hope this helps!
Thanks,
Augustin.
Edited by: Augustarian on Aug 20, 2009 10:06 AM -
Its very urgent:How to insert data one table to another table
Hi all,
i am very new to oaf.
i have employee_number(per_all_people_f) lov is there.once select the employee number and click on the submit button
what ever select the employee number it ll move to new_operation_manager in custom table.
plz help me how to move.
its very urgent.
Thanks
Latha.
Edited by: Latha on Dec 21, 2011 9:33 PMHi Gyan,
Sorry, i will not repate.how to close the thread.
Gyan i have no knowledge on this issue.
plz help me.and where to mention,data is which table to insert.
plz send one sample code.
its very urgent gyan.
i wrote the am,co codes
in am:
public void NewoperationManagerLogic()
ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();----> here which vo take
OADBTransaction oadbt=getOADBTransaction();
if(!vo1.isPreparedForExecution())
vo1.executeQuery();
Row row=vo1.createRow();
vo1.insertRow(row);
in Co processrequest:
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.invokeMethod("NewoperationManagerLogic");
in co processform request:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Submit")!=null)
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.getOADBTransaction().commit();
throw new OAException("Records Saved Sucessfully",OAException.INFORMATION);
thanks
latha
Edited by: Latha on Dec 22, 2011 1:26 AM -
How to move field symbol internal table to internal table with header line?
Dear all,
hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
as i know field symbol internal table is without header line..
so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
Please advise...
Thanks
Regard,
ToToRo.
Edited by: @ToToRo@ on Aug 20, 2009 6:16 AMHello,
Try this way:
If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
itab = <itab>.
Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
Now, you can create <wa> as follow:
FIELD-SYMBOLS <wa>.
DATA wa TYPE REF TO DATA.
CREATE DATA wa TYPE LINE OF <itab>.
ASSIGN wa->* to <wa>.
This way your work area is read.
Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
Finally you can use that value to load static internal table.
You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
Hope this helps!
Thanks,
Augustin.
Edited by: Augustarian on Aug 20, 2009 10:06 AM
Maybe you are looking for
-
How to import existing WLS Portal App into Workshop?
I have searched and searched, and tried every different combination of imports, with no success. I have an existing EAR file, with a Portal Application, created for WebLogic. I am able to deploy it to my server, and it works fine. I would like to imp
-
Returning parts to Apple question
I called apple out of warrenty and paid $80 for a new power brick for my display. Was getting curious what went wrong with my original brick and new 100% it was the brick that was bad so I hacked open the brick and saw the grounding point was loose.
-
Tax claddification in BP listed twice
Hi group, In BP (general role) the tax classification subscreen is listed twice. Once in the Identification tab and once in the Control tab. As my customer doesn't use any other fields in the Control tab I set all other fields to hide. The Control ta
-
Could anyone tell me what the best format would be to export 3 min video commercials for 3000 lumin projectors. I am currently using winamp as my video player and sending that through s-video to a video mixer then to the projectors. None of my videos
-
IMAQ ClipboardToImage IMAQ Vision does not support the file type you specified.
Hi. I have been trying out the inventeering INVENTvisionIMAQexample.vi. But i always encoutered an error in the INVENTvisionVFWcopy.vi of "IMAQ ClipboardToImage IMAQ Vision does not support the file type you specified." And the video window does not