Ver Mensaje Individual
  #3  
Viejo 20/01/14, 13:45:15
kelaya kelaya is offline
Junior Member
 
Fecha de Ingreso: ene 2014
Mensajes: 8
gracias por tu respuesta

hola, acabo de probar lo que me indicas pero aun no funciona. Te dejo el codigo a ver si tu puedes ver el error. Es en el perform "tomar_ceco_orden" donde necesito añadir más campos. Mil gracias!

*Grabacion para carga automatica de valores.
PERFORM bdc_dynpro USING 'SAPLACHD' '1000'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BKPF-BUKRS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'BKPF-BUKRS'
gs_file-bukrs. "'LB01'.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PAYM'.
PERFORM bdc_field USING 'RF05A-BUSCS'
'R'.
PERFORM bdc_field USING 'INVFO-ACCNT'
gs_file-accnt. "'400002'.
PERFORM bdc_field USING 'INVFO-BLDAT'
gs_file-bldat."'29.07.2013'.
PERFORM bdc_field USING 'INVFO-XBLNR'
gs_file-xblnr."'Test Indicador'.
PERFORM bdc_field USING 'INVFO-BUDAT'
gs_file-budat."'31.07.2013'.
PERFORM bdc_field USING 'INVFO-WRBTR'
gs_file-wrbtr. "'1000'.
PERFORM bdc_field USING 'INVFO-WAERS'
gs_file-waers."'BRL'.

PERFORM tomar_ceco_orden USING cont
gs_file-bktxt
gs_file-xblnr

"gv_cont
CHANGING "cont1
band.
PERFORM bdc_field USING 'ACGL_ITEM-AUFNR(01)'
gs_file-aufnr."'650000084'.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'INVFO-ZLSCH'.
PERFORM bdc_field USING 'INVFO-ZFBDT'
gs_file-zfbdt."'29.07.2013'.
PERFORM bdc_field USING 'INVFO-ZTERM'
gs_file-zterm. "'BR01'.
* PERFORM bdc_field USING 'INVFO-ZBD1T'
* '45'.
PERFORM bdc_field USING 'INVFO-ZLSCH'
gs_file-zlsch."'D'.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=MORE'.
PERFORM bdc_field USING 'BDC_CURSOR'
'INVFO-ZLSCH'.
PERFORM bdc_field USING 'INVFO-ZFBDT'
gs_file-zfbdt."'31.07.2013'.
PERFORM bdc_field USING 'INVFO-ZTERM'
gs_file-zterm. "'BR01'.
PERFORM bdc_field USING 'INVFO-ZLSCH'
gs_file-zlsch."'D'.
PERFORM bdc_field USING 'INVFO-ZLSPR'
gs_file-zlspr."'G'.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'BDC_CURSOR'
'INVFO-BKTXT'.
PERFORM bdc_field USING 'INVFO-BKTXT'
gv_cont.
"gs_file-bktxt."'FAT_LB_0000000023'.
PERFORM bdc_dynpro USING 'SAPMF05A' '1100'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BS'.
PERFORM bdc_field USING 'BDC_CURSOR'
'INVFO-BKTXT'.
PERFORM bdc_field USING 'INVFO-BKTXT'
* INI - INDRA065 - 06.08.2013 16:58:21

PERFORM bdc_dynpro USING 'SAPMSSY0' '0120'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BU'.
PERFORM f_z_bdc_transaction USING 'FB60' gv_mode 'S' cont1
gs_file-bukrs
lv_year
gv_cont
gt_opt-dismode
gt_opt-defsize
CHANGING p_ban.
ENDIF.
ENDLOOP.


FORM tomar_ceco_orden USING p_cont
p_bktxt
p_xblnr

CHANGING "p_cont1
p_band.

FIELD-SYMBOLS: <fs_punt1> LIKE LINE OF gt_file,
<fs_file> LIKE LINE OF gt_file.
DATA lv_par TYPE string VALUE '(0'.
DATA lv_par1 TYPE string VALUE ')'.
DATA gs_file2 TYPE t_file.
DATA: lv_hkont TYPE string, "VALUE 'ACGL_ITEM-HKONT',
cont TYPE i VALUE 1,
cont1(2) TYPE c VALUE '01', "modificado carotanus indra065
band6 TYPE i VALUE 0, "modificado carotanus indra065
lv_wrbtr TYPE string," VALUE 'ACGL_ITEM-WRBTR',
lv_sgtxt TYPE string," VALUE 'ACGL_ITEM-SGTXT',
lv_kostl TYPE string," VALUE 'ACGL_ITEM-KOSTL',
lv_aufnr TYPE string," value 'ACGL_ITEM-AUFNR'.
band5 TYPE string VALUE 'FALSE'.

LOOP AT gt_file ASSIGNING <fs_file>.
* nombre de los campos que se setearan
lv_hkont = 'ACGL_ITEM-HKONT'.
lv_wrbtr = 'ACGL_ITEM-WRBTR'.
lv_sgtxt = 'ACGL_ITEM-SGTXT'.
lv_kostl = 'ACGL_ITEM-KOSTL'.
lv_aufnr = 'ACGL_ITEM-AUFNR'.

IF <fs_file> IS ASSIGNED.
*si la cabecera del texto coincide con el informado en la estructura
*se toman los datos faltantes
IF <fs_file>-bktxt EQ p_bktxt AND <fs_file>-band NE 'True'
AND ( <fs_file>-xblnr EQ p_xblnr OR <fs_file>-xblnr EQ ' ').
READ TABLE gt_file ASSIGNING <fs_punt1>"<fs_file>
INDEX p_cont.
IF <fs_punt1> IS ASSIGNED. "<fs_file>

*se forman los nombres de los campos que van a ser utilizados
CONCATENATE lv_hkont lv_par cont1 lv_par1 INTO lv_hkont.
CONCATENATE lv_wrbtr lv_par cont1 lv_par1 INTO lv_wrbtr.
CONCATENATE lv_sgtxt lv_par cont1 lv_par1 INTO lv_sgtxt.
CONCATENATE lv_kostl lv_par cont1 lv_par1 INTO lv_kostl.
CONCATENATE lv_aufnr lv_par cont1 lv_par1 INTO lv_aufnr.
*se pasan los campos que seran cargados por la fb60

IF band5 = 'TRUE'.
band6 = '1'.

PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.



ENDIF.

PERFORM bdc_field USING lv_hkont
* <fs_file>
<fs_punt1>-hkont."'615011101P'.
PERFORM bdc_field USING lv_wrbtr
* <fs_file>
<fs_punt1>-wrbtr_item."'800'.
PERFORM bdc_field USING lv_sgtxt
* <fs_file>
<fs_punt1>-sgtxt.
* Si la orden no es vacia
IF NOT <fs_punt1>-aufnr IS INITIAL.
PERFORM bdc_field USING lv_aufnr
* <fs_file>
<fs_punt1>-aufnr.
ELSE.
IF NOT <fs_punt1>-kostl IS INITIAL.
PERFORM bdc_field USING lv_kostl
* <fs_file>
<fs_punt1>-kostl.
"'1010601'.
ENDIF.
ENDIF.

* se limpian las variables usadas.
CLEAR: lv_hkont, lv_wrbtr, lv_sgtxt, lv_kostl, lv_aufnr.
p_cont = p_cont + 1.
cont1 = cont1 + 1.

IF p_cont = '11'.
band5 = 'TRUE'.
band6 = 1.

ENDIF.

IF band6 EQ '1'.
cont1 = '11'.
band6 = '0'.
CLEAR band6.
ENDIF.

ENDIF.
ELSE.
*en caso de que el doc tenga mas de un ceco para imputar y la cabecera
* de texto no sea igual se setea una bandera que controla que este dato
* sea cargado y se informe.
IF <fs_file>-bukrs EQ ' ' AND <fs_file>-bktxt NE p_bktxt.
<fs_file>-band = 'T032'.
MODIFY gt_file FROM <fs_file>.
CONTINUE.
ELSE.
IF <fs_file>-bktxt EQ p_bktxt AND
( <fs_file>-xblnr NE p_xblnr OR <fs_file>-xblnr NE ' ' ).
<fs_file>-band = 'T031'.
MODIFY gt_file FROM <fs_file>.
CONTINUE.
ENDIF.
ENDIF.
* en caso de que no sea la misma cabecera se continua
* lupeando hasta encontrar la misma.
CONTINUE.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " TOMAR_CECO_ORDEN
Responder Con Cita