PDA

Ver la Versión Completa : Ayuda carga servicios


Skadeour
10/04/06, 07:50:44
Hola necesitaría saber como usar la bapi BAPI_ENTRYSHEET_CREATE para teniendo un pedido ya creado y una posicion te cree una linea de cabecera ESSR Y una linea de servicio ESLL, con solo pasarle el nº pedido EBLN y la posicion EBLP, asi como la cantidad MENGE y la unidad de medida MEINS para crear la linea servicios.
Muchas Gracias

tracer
10/04/06, 09:20:37
Hola Skadeour,

Te adjunto un programa ejemplo en el que se usa la bapi

BAPI_ENTRYSHEET_CREATE

que nos comentas. Quizas te pueda servir como modelo o guía.


* Selecciona item de pedido
DATA: BEGIN OF t_ped OCCURS 0,
ebeln LIKE ekko-ebeln, " Pedido
ebelp LIKE ekpo-ebelp, " Iten del pedido
txz01 LIKE essr-txz01, " Texto de la hoja de entrada de serv
dlort LIKE essr-dlort, " Local de Prest Servicios
lzvon LIKE essr-lzvon, " Periodo de
lzbis LIKE essr-lzbis, " Periodo hasta
sbnamag LIKE essr-sbnamag, " Resp Interno
sbnaman LIKE essr-sbnaman, " Resp Externo
pwwe LIKE essr-pwwe, " Calidad del servicio
pwfr LIKE essr-pwfr, " Plazos del servicio
packno LIKE ekpo-packno, " paquete de servivio
menge LIKE ekpo-menge,
END OF t_ped.

DATA: t_uesll LIKE esll OCCURS 0 WITH HEADER LINE,
t_enc LIKE seqg3 OCCURS 0 WITH HEADER LINE.

SELECT * FROM ekpo INTO CORRESPONDING FIELDS OF TABLE t_ped
WHERE ebeln = w_ebeln.

LOOP AT t_ped.

t_ped-lzvon = sy-datum.
t_ped-lzbis = sy-datum.
t_ped-sbnamag = sy-uname.
t_ped-sbnaman = sy-uname.
t_ped-pwwe = '75'.
t_ped-pwfr = '75'.
t_ped-menge = 1.

MODIFY t_ped.

ENDLOOP.

SORT t_ped.
w_pos = 0.
LOOP AT t_ped.

w_pos = w_pos + 1 .
REFRESH: po_services, t_uesll.
* Busca los servicios del item de pedido
CALL FUNCTION 'MS_READ_SERVICES'
EXPORTING
i_hpackno = t_ped-packno
TABLES
t_esll = t_uesll
EXCEPTIONS
not_found = 1
OTHERS = 2.

CHECK NOT t_uesll[] IS INITIAL.

* Llena tabla de cabecera y detalle de hoja de entrada de servicio
CLEAR po_entrysheet.
po_entrysheet-po_number = t_ped-ebeln.
po_entrysheet-po_item = t_ped-ebelp.
po_entrysheet-begdate = sy-datum.
po_entrysheet-enddate = sy-datum.
po_entrysheet-pckg_no = '1'.
po_entrysheet-person_int = t_ped-sbnamag.
po_entrysheet-person_ext = t_ped-sbnaman.
po_entrysheet-score_time = t_ped-pwwe.
po_entrysheet-score_qual = t_ped-pwfr.
po_entrysheet-short_text = t_ped-txz01.
po_entrysheet-location = t_ped-dlort.
po_entrysheet-acceptance = 'X'.
po_entrysheet-doc_date = sy-datum.
po_entrysheet-post_date = sy-datum.

CLEAR po_services.
po_services-pckg_no = '1'.
po_services-line_no = '1'.
po_services-outl_ind = 'X'.
po_services-subpckg_no = '2'.
po_services-quantity = '1'.
APPEND po_services.

LOOP AT t_uesll WHERE package IS initial.
po_services-pckg_no = '2'.
po_services-line_no = po_services-line_no + 1.
po_services-outl_ind = ' '.
CLEAR po_services-subpckg_no.
po_services-quantity = t_uesll-menge.
po_services-base_uom = t_uesll-meins.
po_services-price_unit = t_uesll-peinh.
IF t_uesll-menge GT 0.
po_services-gr_price = t_uesll-netwr / t_uesll-menge.
ENDIF.
po_services-pln_pckg = t_uesll-packno.
po_services-pln_line = t_uesll-introw.
po_services-short_text = t_uesll-ktext1.
APPEND po_services.
ENDLOOP.

* si no se coloca el commit work and wait transaccion se queda
* bloqueada hasta unos segundos
* espera usuario desbloquear
CONCATENATE sy-mandt t_ped-ebeln INTO w_garg.

REFRESH t_enc.
DO 1000 TIMES.

COMMIT WORK AND WAIT.
REFRESH t_enc.
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = sy-mandt
gname = EKKO
garg = w_garg
TABLES
enq = t_enc
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.

IF sy-subrc NE 0 OR t_enc[] IS INITIAL.
EXIT.
ENDIF.

ENDDO.

* BAPI para crear hoja de entrada de servicios
CALL FUNCTION 'BAPI_ENTRYSHEET_CREATE'
EXPORTING
entrysheetheader = po_entrysheet
IMPORTING
entrysheet = w_entrysheet
TABLES
entrysheetservices = po_services
return = return2.

LOOP AT return2 WHERE type = 'E'.
CLEAR t_errores.
t_errores-mov = 'H/E'.
t_errores-msg = return2-message.
APPEND t_errores.
ENDLOOP.

Un saludo :D .

Skadeour
10/04/06, 10:29:09
Realmente ese ejemplo ya le intente cargar, pero tiene incoherencia de datos, y no esta bien testeado. pero muchas gracias

hugogo_90
19/04/09, 18:00:55
Realmente ese ejemplo ya le intente cargar, pero tiene incoherencia de datos, y no esta bien testeado. pero muchas gracias

Saludos, yo tenia que hacer un programa igual, tome como base este ejemplo y funciono corectamente creaando una hoja de servicio tomamdo el pedido y su posición..

Te agradezco de antemano por su poyo.


Gracias por su apoyo.

jcpv
28/07/10, 21:09:15
Hola, he estando observando el ejemplo que han colocado y me pareció muy interesante, sin embargo quería preguntarles si han obtenido algun error creando la hoja de servicios indicado que se ha observado un indice duplicado en la funcion xmcekpo_cut_lis.
Estoy estancado con este punto y no encuentro solución al respecto.
Si pueden ayudarme con esto, se lo agradecería.

sanchezgc
08/08/11, 14:51:43
otro ejemplo: Copia del pedido a la ml81 las imputaciones etc. Mi problema es que no consigo asignarlo a otro ceco.
**************************************
* CABECERA
**************************************
entrysheetheader-sheet_no = '1'. "gt_ekpo-packno.
entrysheetheader-ext_number = 'HE TEXTO'.
entrysheetheader-person_int = sy-uname.
entrysheetheader-person_ext = sy-uname.
* entrysheetheader-location = t_ekpo-lgort.
entrysheetheader-ref_date = SY_DATUM "UNA FECHA.
* entrysheetheader-begdate = vl_date.
* entrysheetheader-enddate = vl_date.
entrysheetheader-pckg_no = '1'."gt_ekpo-packno.
entrysheetheader-short_text = vl_texto.
entrysheetheader-po_number = gt_ekpo-ebeln.
entrysheetheader-po_item = '0010'.
entrysheetheader-block_ind = vl_block. "X
entrysheetheader-doc_date = fec.
entrysheetheader-post_date = fec.
entrysheetheader-ref_doc_no = vl_nota. "Un texto not ade entrega
entrysheetheader-accasscat = 'K'. "imputación a ceco
* entrysheetheader-acceptance = 'X'. "Se pide que no sean aceptados
**************************************
* registros account assigment
**************************************
CLEAR vl_num.

LOOP AT lt_ekkn.
ADD 1 TO vl_num.
"Nº paquete
entrysheetaccountassignment-pckg_no = '1'."gt_ekpo-packno.
"Nºactual imput.
entrysheetaccountassignment-serial_no = vl_num.

"Centro de coste
entrysheetaccountassignment-costcenter = vl_kostl.
"Sociedad CO
entrysheetaccountassignment-co_area = wa_ekko-bukrs. '.

IF vl_lemin IS INITIAL.
"Número de la cuenta de mayor
entrysheetaccountassignment-gl_account = lt_ekkn-sakto.
"Centro de beneficio
entrysheetaccountassignment-profit_ctr = lt_ekkn-prctr.
"Elemento del plan de estructura de proyecto (elemento PEP)
PERFORM pep_output_sin
USING lt_ekkn-ps_psp_pnr
CHANGING entrysheetaccountassignment-wbs_elem.
"Posición presupuestaria
entrysheetaccountassignment-cmmt_item = lt_ekkn-fipos.
ENDIF.
CASE vl_lemin.
WHEN lc_equis.
CHECK vl_num = 1.
APPEND entrysheetaccountassignment.
WHEN OTHERS.
APPEND entrysheetaccountassignment.
ENDCASE.

ENDLOOP.
**************************************
* SERVICIOS
**************************************
"Nº paquete - Linea de cabecera servicios
entrysheetservices-pckg_no = '1'."gt_ekpo-packno.
"Número de líneas interno
entrysheetservices-line_no = '0000000001'.
"Número de línea
entrysheetservices-ext_line = '0000000010'.
"Nivel jerárquico del grupo
entrysheetservices-outl_level = '0'.
* entrysheetservices-OUTL_NO "Nivel de estructura
entrysheetservices-outl_ind = 'X'. "Indicador línea estructurac.
"Número de subpaquete
entrysheetservices-subpckg_no = '2'."gt_ekpo-packno + 1.
"Entrada: no planif., línea límite
entrysheetservices-limit_line = pt_tab-impor.
IF vl_lemin = 'X'.
* Si es devolucion importe negativo a positivo
entrysheetservices-limit_line = entrysheetservices-limit_line * -1.
ENDIF.
APPEND entrysheetservices.
* SEGUNDA linea detalle servicios
CLEAR entrysheetservices.
"Nº paquete
entrysheetservices-pckg_no = '2'."gt_ekpo-packno + 1.
"Número de líneas interno
entrysheetservices-line_no = '0000000002'.
entrysheetservices-ext_line = '0000000010'.
"Cantidad con signo +/-
entrysheetservices-quantity = gt_ekpo-menge.
"Unidad de medida base
entrysheetservices-base_uom = gt_ekpo-meins.
* entrysheetservices-UOM_ISO "Código ISO p.unidad de medida?
"Cantidad base
entrysheetservices-price_unit = gt_ekpo-peinh.
"Precio bruto
entrysheetservices-gr_price = pt_tab-impor .
IF vl_lemin = 'X'.
"El importe se deberá pasar como positivo
entrysheetservices-gr_price = entrysheetservices-gr_price * -1.
ENDIF.
entrysheetservices-short_text = vl_texto. "Texto breve
*------------------------------------------------------
* Indicador de distribución en la imputación múltiple
*' 'Imputación simple
*1 Distribución por cantidades
*2 Distribución porcentual
*-----------------------------------------------------
IF vl_lemin IS INITIAL.
entrysheetservices-distrib = '2'.
ELSE.
entrysheetservices-distrib = space.
ENDIF.
"Entrada: no planif., línea límite
* entrysheetservices-LIMIT_LINE = pt_tab-impor.
"Grupo de artículos = 03
entrysheetservices-matl_group = gt_ekpo-matkl.
APPEND entrysheetservices.

**************************************
* SRV ACCESS VALUE - IMPUTACIONES
**************************************
* NOTA: Si en el paso anterior se marca imputación simple no hará caso
* a la distribución distribuida de acontinuación
CLEAR vl_num.
LOOP AT lt_ekkn.
CLEAR entrysheetsrvaccassvalues.
ADD 1 TO vl_num.
IF vl_num = 1.
"Nº paquete - Linea cabecera
entrysheetsrvaccassvalues-pckg_no = '1'. "gt_ekpo-packno.
"Número de línea
entrysheetsrvaccassvalues-line_no = vl_num.
"Número correlativo asign. imputación línea de servicio
entrysheetsrvaccassvalues-serno_line = vl_num.
"Número actual imputación
entrysheetsrvaccassvalues-serial_no = vl_num.
CASE vl_lemin. "Indicador de devolucion
WHEN lc_equis.
"Porcentaje
entrysheetsrvaccassvalues-percentage = 100.
"Cantidad con signo +/-
entrysheetsrvaccassvalues-quantity = 1 .
"Valor neto de la posición
entrysheetsrvaccassvalues-net_value = pt_tab-impor.
WHEN OTHERS.
"Porcentaje
entrysheetsrvaccassvalues-percentage = lt_ekkn-vproz.
"Cantidad con signo +/-
entrysheetsrvaccassvalues-quantity =
1 * ( lt_ekkn-vproz / 100 ).
"Valor neto de la posición
entrysheetsrvaccassvalues-net_value = pt_tab-impor.
ENDCASE.
APPEND entrysheetsrvaccassvalues.
ELSE.
CHECK vl_lemin IS INITIAL.
"Nº paquete - RESTO DE LINEAS
entrysheetsrvaccassvalues-pckg_no = '1'. "gt_ekpo-packno.
"Número de línea
entrysheetsrvaccassvalues-line_no = vl_num.
"Número correlativo asign. imputación línea de servicio
entrysheetsrvaccassvalues-serno_line = vl_num.
"Porcentaje
entrysheetsrvaccassvalues-percentage = lt_ekkn-vproz.
"Número actual imputación
entrysheetsrvaccassvalues-serial_no = vl_num.
"Cantidad con signo +/-
entrysheetsrvaccassvalues-quantity =
1 * ( lt_ekkn-vproz / 100 ).
"Valor neto de la posición
entrysheetsrvaccassvalues-net_value = pt_tab-impor.

APPEND entrysheetsrvaccassvalues.
ENDIF.

ENDLOOP.


COMENTAR: esto vale para llamar a la bapi, pero yo para el indicador de dev. tuve que copiar dicha bapi a un MF, una rutina y la llamada a la función adecuando datos.

fenixse7
24/04/12, 14:44:36
Hola buenos dias, pudiste solucionarlo? Tengo el mismo problema...

Gracias!