Skip to Content
avatar image
-2
Former Member

SUM quatity field produce in the same hour.

Hello experts.

I have a problem, i have 2 tag fields that i need to some the quantity on the same hour.

Since there are 2 production lines there are these 2 TAG's. If we want to know the quantity produced in a given hour, we will have to add the quantities of these two TAG's

TAGS:

  • FTHME1.PELLETIZING.WE_3400_Hourly_Production,Total,Hourly
  • FTHME1.PELLETIZING.WE_4400_Hourly_Production,Total,Hourly

How to put this on my code?

My code is:

FORM create_doc TABLES p_lt_goodsmv_dcs STRUCTURE zmm_goodsmv_dcs
USING p_move_type
p_gm_code
p_werks
p_lgort.

DATA lr_cre_goodsmv TYPE REF TO zcl_mm_create_goodsmv_colombo.
DATA lv_prod_date TYPE atflv.
DATA lv_prod_hour TYPE atflv.
DATA lv_prod_hour_aux TYPE uzeit.
DATA lv_hour_dec TYPE p.
DATA lv_hour_int TYPE i.
DATA lv_hour_char TYPE char2.

DATA ls_goodsmv_dcs TYPE zmm_goodsmv_dcs.
DATA ls_dcs_matnr TYPE zmm_dcs_matnr.
DATA lv_error TYPE abap_bool.

DATA lv_uzeit TYPE sy-uzeit.
DATA lv_value TYPE menge_d.

DATA ls_dcs_aux TYPE zmm_goodsmv_dcs.
DATA lt_dcs_aux TYPE TABLE OF zmm_goodsmv_dcs.

lv_uzeit = sy-uzeit. "hora processamento.



LOOP AT p_lt_goodsmv_dcs INTO ls_goodsmv_dcs.
IF ls_goodsmv_dcs-imported EQ ''
AND ls_goodsmv_dcs-confidence EQ '100'.

CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
EXPORTING
input = ls_goodsmv_dcs-menge
matnr = ls_goodsmv_dcs-matnr
meinh = 'TO'
meins = 'TON'
werks = p_werks
IMPORTING
output = lv_value
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.


CREATE OBJECT lr_cre_goodsmv TYPE zcl_mm_create_goodsmv_colombo
EXPORTING
iv_matnr = ls_dcs_matnr-matnr
iv_werks = p_werks
iv_lgort = p_lgort
iv_origin = zcl_mm_create_goodsmv_colombo=>sv_int_manual
iv_menge = lv_value
iv_meins = 'TO'.

* lr_cre_goodsmv->clear_error( ).

lv_prod_date = zcl_mm_create_goodsmv_colombo=>conv_date_to_atflv(
ls_goodsmv_dcs-prddt
).

lv_prod_hour = zcl_mm_create_goodsmv_colombo=>conv_hour_to_atflv(
ls_goodsmv_dcs-prdhr
).

lr_cre_goodsmv->add_classification_char(
iv_char = zcl_mm_create_goodsmv_colombo=>sv_data_prod_class
iv_value = lv_prod_date
).

lr_cre_goodsmv->add_classification_char(
iv_char = zcl_mm_create_goodsmv_colombo=>sv_hora_prod_class
iv_value = lv_prod_hour
).

lr_cre_goodsmv->make( ).
IF lr_cre_goodsmv->is_error( ) NE abap_true.
lr_cre_goodsmv->change_goodsmv_dcs( ls_goodsmv_dcs ).
ENDIF.

"WAIT UP TO 10 SECONDS.
* lr_cre_goodsmv->show_messages( abap_true ).
ENDIF.
ENDLOOP.
* lr_cre_goodsmv->show_messages( abap_true ).

lr_cre_goodsmv->save_log( ).
lr_cre_goodsmv->show_all_log( lv_uzeit ).

ENDFORM. " CREATE_DOC

Add comment
10|10000 characters needed characters exceeded

  • I don't understand, the problem seems very basic, you keep the hours from a given time, and you do the sum of quantities using the statement COLLECT.

    If the problem is more complex, could you give an example of input values, and what you expect?

  • Former Member

    hello sandra Rossi tks for the reply, the problem i dont know how to do the collect statment,

    the problem says Since there are 2 production lines there are these 2 TAG's. If we want to know the quantity produced in a given hour, we will have to add the quantities of these two TAG's, if the tags have the same hours they will sum the quantitys.

    Can you explain me how to do it give me some example.

    im a newbie, on sap and i dont know where to apply it.

    i think i need to do on the loop statmnet.

  • Former Member

    Maybe i could do on the select??

    my select is this

    DATA: lt_goodsmv_tag TYPE TABLE OF zmm_goodsmv_tag,
    ls_goodsmv_tag TYPE zmm_goodsmv_tag.

    SELECT * FROM zmm_goodsmv_tag
    INTO CORRESPONDING FIELDS OF TABLE lt_goodsmv_tag.

    IF lt_goodsmv_tag[] IS NOT INITIAL.

    SELECT TAGPC MATNR PRDDT PRDHR MENGE MEINS VALUE_TYPE FREQUENCY CONFIDENCE TIMESTAMP IMPORTED IMP_SGF FROM zmm_goodsmv_dcs
    INTO CORRESPONDING FIELDS OF TABLE p_lt_goodsmv_dcs
    FOR ALL ENTRIES IN lt_goodsmv_tag
    WHERE imported EQ ''
    AND prddt IN so_prddt
    AND tagpc = lt_goodsmv_tag-tagpc
    AND value_type = lt_goodsmv_tag-value_type
    AND frequency = lt_goodsmv_tag-frequency.

  • Get RSS Feed

0 Answers