Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Data are not recorded in table AFRU

Former Member
0 Kudos

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.

2 REPLIES 2

Former Member
0 Kudos

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
.

nabheetscn
Active Contributor
0 Kudos

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.