PDA

Ver la Versión Completa : Problema con carga masiva.


Robert80
10/05/12, 18:27:35
Hola a todos, es sobre la carga masiva que hice hace un par de meses atrás... quiero cambiar una parte del código y ya le movi y le cambie y no logro como hacer esta modificacion... todo se carga desde un excel pero hay un parametro donde se pide que no sea obligatoria una fecha y jajajaja pues no logro esto... ojala alguien me pueda orientar gracias anexo parte del codigo...

*&---------------------------------------------------------------------*
*& Form CARGA_RT_ACCIDENTE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form carga_rt_accidente .
data l_pernr type pernr.
data l_pernr2 type pernr.
data l_variable type string.
data l_cadena type i.
data L_ok type c LENGTH 2.
data l_messege type c length 100.
data l_fecha_llave type c length 10.
data l_fecha1 type c length 10.
data l_fecha2 type c length 10.
data l_fecha3 type c length 10.
data l_fecha4 type c length 10.
data l_conse type i.

clear: l_conse, g_excel, g_procesados, g_guardados, g_rechazados.

loop at IT_RTACCI into w_rtacci.
if w_rtacci-campo01(5) eq ''.
delete IT_RTACCI index sy-tabix.
else.
add 1 to l_conse.

if l_conse eq 2.
exit.
endif.
delete IT_RTACCI index sy-tabix.
endif.
endloop.

describe table IT_RTACCI lines g_excel.


loop at it_rtacci into w_rtacci.
if w_rtacci-campo01 is not initial.
"l_pernr = w_rtacci-campo01(5).
SPLIT w_rtacci-campo01 AT '-' INTO l_pernr l_pernr2.

concatenate w_rtacci-campo05(2) '.'
w_rtacci-campo05+3(2) '.'
w_rtacci-campo05+6(4)
into l_fecha1.

concatenate w_rtacci-campo06(2) '.'
w_rtacci-campo06+3(2) '.'
w_rtacci-campo06+6(4)
into l_fecha2.

concatenate w_rtacci-campo15(2) '.'
w_rtacci-campo15+3(2) '.'
w_rtacci-campo15+6(4)
into l_fecha3.

concatenate w_rtacci-campo16(2) '.'
w_rtacci-campo16+3(2) '.'
w_rtacci-campo16+6(4)
into l_fecha4.

perform llena tables bdc_dat
using: 'X' 'SAPMP50A' '1000',
' ' 'BDC_OKCODE' '=INS',
' ' 'RP50G-PERNR' l_pernr,
' ' 'RP50G-TIMR6' 'X',
' ' 'BDC_CURSOR' 'RP50G-SUBTY',
' ' 'RP50G-CHOIC' '9928',
' ' 'RP50G-SUBTY' 'F001'.

perform llena tables bdc_dat
using: 'X' 'MP992800' '2000',
' ' 'BDC_CURSOR' 'ZQ9928-VALA(08)',
' ' 'P9928-EXDAT' l_fecha1,
' ' 'P9928-LXDAT' l_fecha2,
' ' 'P9928-RESUL' w_rtacci-campo08(2),
' ' 'P9928-DIAGNOS' w_rtacci-campo09(3),
' ' 'P9928-TRATAM' w_rtacci-campo10(3),
' ' 'P9928-PRONOST' w_rtacci-campo11(3),
' ' 'P9928-RESTRIC' w_rtacci-campo12(3),
' ' 'P9928-RESTRIC_A' w_rtacci-campo13(3),
' ' 'ZQ9928-VALA(01)' w_rtacci-campo14(4),
' ' 'ZQ9928-VALA(02)' l_fecha3,
' ' 'ZQ9928-VALA(03)' l_fecha4,
' ' 'ZQ9928-VALA(04)' w_rtacci-campo17(10),
' ' 'ZQ9928-VALA(05)' w_rtacci-campo18(10),
' ' 'ZQ9928-VALA(06)' w_rtacci-campo19(10),
' ' 'ZQ9928-VALA(07)' w_rtacci-campo20(10),
' ' 'ZQ9928-VALA(08)' w_rtacci-campo21(10),
' ' 'BDC_OKCODE' '=P+'.

perform llena tables bdc_dat
using: 'X' 'MP992800' '2000',
' ' 'BDC_CURSOR' 'ZQ9928-VALA(02)',
' ' 'ZQ9928-VALA(01)' w_rtacci-campo22(10),
' ' 'ZQ9928-VALA(02)' w_rtacci-campo23(10),
' ' 'BDC_OKCODE' '=UPD'.

clear: l_variable, L_OK.
concatenate w_rtacci-campo08 w_rtacci-campo09 w_rtacci-campo10
w_rtacci-campo11 w_rtacci-campo12 w_rtacci-campo13
w_rtacci-campo14 w_rtacci-campo17 w_rtacci-campo18
w_rtacci-campO19 w_rtacci-campo20 w_rtacci-campo21
l_fecha1 l_fecha2 l_fecha3 l_fecha4
into L_variable.
l_cadena = STRLEN( L_variable ).

if l_cadena >= 1.
call transaction 'PA30'
using bdc_dat options from opt messages into msgs.

if sy-subrc eq 0.
l_ok = 'ok'.
else.
l_ok = 'no'.
endif.
else.
l_ok = 'no'.
endif.

"1111111111111
add 1 to g_procesados.

if l_ok = 'ok'.
add 1 to g_guardados.
elseif l_ok = 'no'.
add 1 to g_rechazados.

w_logini2-mandt = sy-mandt.
w_logini2-erdat = w_logini-erdat.
w_logini2-erzet = w_logini-erzet.

w_logini2-ernam = sy-uname.
case g_file1.
when '1000'.
w_logini2-carga = 'Exa Med'.
when '0100'.
w_logini2-carga = 'RT Accidente'.
when '0010'.
w_logini2-carga = 'Enf Gral'.
when '0001'.
w_logini2-carga = 'RT IPP EnTr'.
endcase.

w_logini2-PERNR = l_pernr.
w_logini2-estatus = text-001.

insert zhr_cargachm2 from w_logini2.
endif.
* call transaction 'PA30'
* using bdc_dat options from opt messages into msgs.
*
* add 1 to g_procesados.
*
* if sy-subrc eq 0.
* add 1 to g_guardados.
* else.
* add 1 to g_rechazados.
*
* w_logini2-mandt = sy-mandt.
* w_logini2-erdat = w_logini-erdat.
* w_logini2-erzet = w_logini-erzet.
*
* w_logini2-ernam = sy-uname.
* case g_file1.
* when '1000'.
* w_logini2-carga = 'Exa Med'.
* when '0100'.
* w_logini2-carga = 'RT Accidente'.
* when '0010'.
* w_logini2-carga = 'Enf Gral'.
* when '0001'.
* w_logini2-carga = 'RT IPP EnTr'.
* endcase.
*
* w_logini2-PERNR = l_pernr.
* w_logini2-estatus = text-001.
*
* insert zhr_cargachm2 from w_logini2.
* endif.

* if sy-subrc eq 0.
* add 1 to g_guardados.
* else.
* add 1 to g_rechazados.
* endif.
clear bdc_dat.
refresh bdc_dat.
concatenate 'Se ha procesado el empleado No ' l_pernr(8) into l_messege respecting blanks.
mensaje l_messege.
else.
add 1 to g_rechazados.
endif.
endloop.

endform. " CARGA_RT_ACCIDENTE