Skip to Content
author's profile photo Former Member
Former Member

Data are not recorded in table AFRU

Good experts days scn, the following code can not write data to the AFRU table, I have made the respective debbug and if it shows that the data are added in the AFRU table, but at the end of the program and check in table these data are not recorded, please tell me what could I lack in the code to record those records.


FORM toma_de .
DATA: l_n1 TYPE afru-rueck,
l_n2 TYPE afru-rueck,
lv_total TYPE i.

REFRESH: ti_log.

LOOP AT ti_input INTO st_input.
CLEAR:it_afru.

MOVE: st_input-aufnr TO it_afru-aufnr,
st_input-vornr TO it_afru-vornr,
st_input-budat TO it_afru-budat,
st_input-zzcant1 TO it_afru-zzcant1,
st_input-zzmot1 TO it_afru-zzmot1,
st_input-zzcant2 TO it_afru-zzcant2,
st_input-zzmot2 TO it_afru-zzmot2,
st_input-zzcant3 TO it_afru-zzcant3,
st_input-zzmot3 TO it_afru-zzmot3,
st_input-zzcant4 TO it_afru-zzcant4,
st_input-zzmot4 TO it_afru-zzmot4,
st_input-ltxa1 TO it_afru-ltxa1,
st_input-rueck TO it_afru-rueck.


DATA: l_budat(10) TYPE c,
l_result(10) TYPE c.
l_budat = it_afru-budat.
CONCATENATE l_budat+6(2)'.'l_budat+4(2)'.'l_budat+0(4) INTO l_result.

PERFORM bdc_dynpro USING :
'X' 'SAPLCORU_S' '0100',
' ' 'BDC_OKCODE' '/00',
' ' 'AFRUD-RUECK' it_afru-rueck,
' ' 'AFRUD-AUFNR' it_afru-aufnr,
' ' 'AFRUD-VORNR' it_afru-vornr,
' ' 'AFRUD-BUDAT' l_result. "Fecha

PERFORM bdc_dynpro USING :
'X' 'SAPLCORU_S' '0100',
' ' 'BDC_OKCODE' '=BU', "Grabar
' ' 'AFRUD-AUFNR' it_afru-aufnr,
' ' 'AFRUD-VORNR' it_afru-vornr,
' ' 'AFRUD-BUDAT' l_result,
' ' 'AFRUD-RUECK' it_afru-rueck.

s_opt-dismode = c_mod.
s_opt-updmode = c_update.
s_opt-nobinpt = ' '.
CALL TRANSACTION 'CO11N' USING it_bdc_tab[]
OPTIONS FROM s_opt
MESSAGES INTO it_messtab[].

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING
input = it_afru-vornr
IMPORTING
output = it_afru-vornr.

CALL FUNCTION 'PM_ORDER_DATA_READ'
EXPORTING
order_number = st_input-aufnr " aufk-
TABLES
iafvgd = it_func " afvgd

EXCEPTIONS
order_not_found = 1.

SORT it_func BY rueck rmzhl DESCENDING.
READ TABLE it_func INDEX 1.
* DESCRIBE TABLE it_func LINES lv_total.

IF sy-subrc = 0.

afru-zzcant1 = it_afru-zzcant1.
afru-zzmot1 = it_afru-zzmot1.
afru-zzcant2 = it_afru-zzcant2.
afru-zzmot2 = it_afru-zzmot2.
afru-zzcant3 = it_afru-zzcant3.
afru-zzmot3 = it_afru-zzmot3.
afru-zzcant4 = it_afru-zzcant4.
afru-zzmot4 = it_afru-zzmot4.
afru-ltxa1 = it_afru-ltxa1.
MODIFY afru FROM TABLE it_afru.
COMMIT WORK.
ENDIF.


ENDLOOP.


Thank you all for your valuable time.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2014 at 04:21 PM

    Hi,

    Please find my initial findings, I guess this is the way to handle!

    - don't write the modify statment with in the loop. Just collect the information in table it_afru

    CALL TRANSACTION 'CO11N' USING it_bdc_tab[]
    OPTIONS FROM s_opt
    MESSAGES INTO it_messtab[].


    * handle the BDC messages properly! In this case irrespectiv success or failure you are updating the AFRU table-- i think this not correct.

    *Don't use the modify stat

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING
    input = it_afru-vornr
    IMPORTING
    output = it_afru-vornr.

    CALL FUNCTION 'PM_ORDER_DATA_READ'
    EXPORTING
    order_number = st_input-aufnr " aufk-
    TABLES
    iafvgd = it_func " afvgd

    EXCEPTIONS
    order_not_found = 1.

    SORT it_func BY rueck rmzhl DESCENDING.
    READ TABLE it_func INDEX 1.
    * DESCRIBE TABLE it_func LINES lv_total.

    IF sy-subrc = 0.

    afru-zzcant1 = it_afru-zzcant1.
    afru-zzmot1 = it_afru-zzmot1.
    afru-zzcant2 = it_afru-zzcant2.
    afru-zzmot2 = it_afru-zzmot2.
    afru-zzcant3 = it_afru-zzcant3.
    afru-zzmot3 = it_afru-zzmot3.
    afru-zzcant4 = it_afru-zzcant4.
    afru-zzmot4 = it_afru-zzmot4.
    afru-ltxa1 = it_afru-ltxa1.

    endloop.


    MODIFY afru FROM TABLE it_afru.
    COMMIT WORK.
    ENDIF
    .

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 11, 2014 at 04:34 PM

    First of all pleade dont update standard tables directly. What exactly are you trying to achieve..? What is the logic for this development please explain.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.