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: 

how to upload the data from .DWG file to sap

Former Member
0 Kudos
162

hi experts,

how could i upload the data from .dwg file to sap system.please help solving this problem

2 REPLIES 2

Former Member
0 Kudos
49

USE THIS CODE

*&----


*

*& Report ZBWSDI002

*&

*&----


*

*& Carga de Venta Scanner Semanal.

*&

*&----


*

REPORT ZBWSDI002

NO STANDARD PAGE HEADING

LINE-SIZE 120 "Anchura del report de nnn caracteres

LINE-COUNT 90 "Comprimento del report de nn caract

MESSAGE-ID ZBWLEY.

*&----


*

  • Includes Requerdos en el Proceso

*include zbsd0002. "Carga de Archivos *.txt

*include zdmii001_v01. "Declaracion de Variables y Estructuras.

*----


*

  • Tablas Dicc.

TABLES: ZTVTASCANNER, SSCRFIELDS.

*----


*

  • de Tipos

TYPES:

BEGIN OF TY_DATA_TAB, "Tabla del Archivo

LINE(1000) TYPE C, "STRING.

END OF TY_DATA_TAB.

TYPE-POOLS: ICON.

*----


*

  • de Constantes

CONSTANTS:

C_MODE(01) TYPE C VALUE 'O', "Tipo Open

C_OK TYPE FLAG VALUE 'X'.

*----


*

  • de Tablas y Estrucutras

DATA:

IT_TABDATOS TYPE TABLE OF TY_DATA_TAB WITH HEADER LINE,

BEGIN OF L_TABCAMPOS,

FECHA(8) TYPE C,

SEMANO(4) TYPE C,

SEMANA(2) TYPE C,

DEPTO(6) TYPE C,

TIENDA(4) TYPE C,

ARTICULO(18) TYPE N,

IMPORTEACT(17) TYPE C,

IMPORTEANT(17) TYPE C,

VOLVENACT(17) TYPE C,

VOLVENANT(17) TYPE C,

UNIVTA(3) TYPE C,

END OF L_TABCAMPOS,

IT_TABCAMPOS LIKE TABLE OF L_TABCAMPOS WITH HEADER LINE,

L_TABCAMANT LIKE L_TABCAMPOS,

IT_LOGT(500) TYPE C OCCURS 0 WITH HEADER LINE,

BEGIN OF L_LOG,

LOGLINE(255) TYPE C,

END OF L_LOG,

IT_LOG LIKE TABLE OF L_LOG,

L_TEXT(50) TYPE C,

*----


*

  • de Variables

V_CHECK TYPE C,

V_HRINI LIKE SY-UZEIT,

V_CON TYPE P,

VTEXT(50) TYPE C,

VPORC TYPE P DECIMALS 2,

V_LINES TYPE I.

*&----


*

  • Patalla con Parametros de Seleccion.

SELECTION-SCREEN BEGIN OF BLOCK S1 WITH FRAME TITLE TEXT-001.

SELECTION-SCREEN SKIP 1.

PARAMETERS:

P_ARCH LIKE RLGRAP-FILENAME DEFAULT TEXT-002 OBLIGATORY.

  • p_group like apqi-groupid default text-014 obligatory.

SELECTION-SCREEN END OF BLOCK S1.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN PUSHBUTTON (13) PUSHY USER-COMMAND JOB.

SELECTION-SCREEN END OF LINE.

AT SELECTION-SCREEN OUTPUT.

*--- Texto del Botón "Crear JOB"

MOVE 'JOB de Fondo' TO PUSHY.

AT SELECTION-SCREEN.

*--- Evento del proceso de fundo, donde se cria un JOB

IF SSCRFIELDS-UCOMM = 'JOB'.

CALL DIALOG 'JOB_SUBMIT'

EXPORTING

RALDB-REPORT FROM SY-REPID

RALDB-VARIANT FROM ' '.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_ARCH.

*--- Busca del archivo con camino del fichero para procesamiento

PERFORM F_ABRIR_ARCHIVO USING TEXT-003 C_MODE TEXT-004

CHANGING P_ARCH.

START-OF-SELECTION.

CLEAR V_CHECK.

V_HRINI = SY-UZEIT.

PERFORM MENSAJE_LOG USING 0 'Inicia Carga de Archivo TXT '.

PERFORM F_BUCSCA_ARCHIVO TABLES IT_TABDATOS USING P_ARCH

CHANGING V_CHECK.

PERFORM MENSAJE_LOG USING 0 'Termino Carga de Archivo TXT '.

CHECK V_CHECK IS INITIAL.

PERFORM MENSAJE_LOG USING 0 'Borrando de tabla ZTVTASCANNER'.

EXEC SQL.

TRUNCATE TABLE ZTVTASCANNER

ENDEXEC.

DELETE FROM ZTVTASCANNER.

COMMIT WORK AND WAIT.

DATA V_TOT TYPE P.

DO.

SELECT SINGLE * FROM ZTVTASCANNER.

IF SY-SUBRC <> 0

OR V_TOT > 1000.

EXIT.

ENDIF.

CLEAR V_CON.

DO 100 TIMES.

V_CON = V_CON + 1.

ENDDO.

V_TOT = V_TOT + V_CON.

ENDDO.

SELECT SINGLE * FROM ZTVTASCANNER.

CHECK SY-SUBRC <> 0.

PERFORM MENSAJE_LOG USING 0 'Termino Borrando de tabla ZTVTASCANNER'.

PERFORM F_TRATAR_TABDATOS.

PERFORM MENSAJE_LOG USING: 0 'Proceso Terminado'.

END-OF-SELECTION.

*----


*

  • Reporte de Resultado

WRITE: /

'Fin de Proceso ... ', /

'Total de Registros: ', V_CON LEFT-JUSTIFIED.

ULINE.

IF IT_LOG IS NOT INITIAL.

WRITE / 'Mensajes Log...'.

LOOP AT IT_LOG INTO L_LOG.

WRITE / L_LOG.

ENDLOOP.

ENDIF.

ULINE.

IF IT_LOGT[] IS NOT INITIAL.

SKIP 1.

CLEAR V_LINES.

DESCRIBE TABLE IT_LOGT LINES V_LINES.

WRITE: / 'Registros Duplicados:', V_LINES.

LOOP AT IT_LOGT.

WRITE / IT_LOGT.

ENDLOOP.

ENDIF.

TOP-OF-PAGE.

WRITE: (29) SY-DATUM LEFT-JUSTIFIED,

(59) 'Interfase de Carga de Venta Scanner' CENTERED,

(30) SY-PAGNO.

ULINE.

*&----


*

*& Form F_ABRIR_ARCHIVO

*&----


*

  • Ayuda para Especificar la ruta de Archivo

*----


*

  • -->P_MASK text

  • -->P_MODE text

  • -->P_TITLE text

  • -->P_FILENAME text

*----


*

FORM F_ABRIR_ARCHIVO USING P_MASK TYPE CHAR80

P_MODE TYPE C

P_TITLE TYPE ANY

CHANGING P_FILENAME LIKE RLGRAP-FILENAME.

DATA: VL_MASK(80) TYPE C,

VL_FILENAME LIKE RLGRAP-FILENAME.

VL_MASK = P_MASK.

CALL FUNCTION 'WS_FILENAME_GET' "#EC

EXPORTING

DEF_FILENAME = P_FILENAME

MASK = VL_MASK

MODE = P_MODE

TITLE = P_TITLE

IMPORTING

FILENAME = VL_FILENAME

EXCEPTIONS

INV_WINSYS = 1

NO_BATCH = 2

SELECTION_CANCEL = 3

SELECTION_ERROR = 4

OTHERS = 5.

IF SY-SUBRC = 0.

P_FILENAME = VL_FILENAME.

ELSEIF SY-SUBRC <> 3.

MESSAGE I008. STOP.

ENDIF.

ENDFORM. " F_ABRIR_ARCHIVO

*&----


*

*& Form F_BUCSCA_ARCHIVO

*&----


*

  • Cargar Archivo Especificado

*----


*

  • -->T_DATA_TAB text

  • -->P_FILENAME text

  • -->V_CHECK text

*----


*

FORM F_BUCSCA_ARCHIVO TABLES T_DATA_TAB STRUCTURE IT_TABDATOS

USING P_FILENAME LIKE RLGRAP-FILENAME

CHANGING V_CHECK TYPE C.

DATA: V_FILENAME TYPE STRING, "Ruta del archivo

E_DATA_TAB LIKE IT_TABDATOS.

CLEAR: V_FILENAME, T_DATA_TAB.

REFRESH: T_DATA_TAB.

IF NOT SY-BATCH IS INITIAL.

      • Abre Archivo

OPEN DATASET P_FILENAME FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

IF SY-SUBRC NE 0.

IF SY-BATCH EQ SPACE.

MESSAGE I320(BF00) WITH P_FILENAME.

ELSE.

MESSAGE S320(BF00) WITH P_FILENAME.

ENDIF.

MOVE 'X' TO V_CHECK.

STOP.

ENDIF.

      • Busca datos del Archivo en servidor

DO.

CLEAR: E_DATA_TAB, V_FILENAME.

READ DATASET P_FILENAME INTO V_FILENAME.

IF SY-SUBRC NE 0.

EXIT.

ELSE.

MOVE V_FILENAME TO E_DATA_TAB.

APPEND E_DATA_TAB TO T_DATA_TAB.

ENDIF.

ENDDO.

      • Cerra Archivo

CLOSE DATASET P_FILENAME. "Cerra Archivo

ELSE.

MOVE P_FILENAME TO V_FILENAME.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FILENAME

TABLES

DATA_TAB = T_DATA_TAB[]

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

IF SY-SUBRC <> 0.

MESSAGE I013.

MOVE 'X' TO V_CHECK.

STOP.

ENDIF.

ENDIF.

IF T_DATA_TAB[] IS INITIAL.

MESSAGE S014 WITH V_FILENAME.

MOVE 'X' TO V_CHECK.

STOP.

ENDIF.

ENDFORM. " F_BUCSCA_ARCHIVO

*&----


*

*& Form F_TRATAR_TABDATOS

*&----


*

  • Rutina para Separar la cadena de texto en campos

*----


*

FORM F_TRATAR_TABDATOS .

DATA: MOFF TYPE I,

MLEN TYPE I,

OFF TYPE I,

LONG TYPE I,

IDFLD TYPE I,

V_LINES TYPE I,

V_MATER(18) TYPE N.

PERFORM MENSAJE_LOG USING 0 'Separando Texto en Campos'.

CLEAR V_CON.

LOOP AT IT_TABDATOS.

OFF = 0.

CLEAR: SY-SUBRC, IDFLD, L_TABCAMPOS.

WHILE SY-SUBRC = 0.

FIND ',' IN SECTION OFFSET OFF OF IT_TABDATOS-LINE

MATCH OFFSET MOFF

MATCH LENGTH MLEN.

IF SY-SUBRC = 0.

CLEAR: LONG, L_TEXT.

IF MOFF > OFF.

LONG = MOFF - OFF.

L_TEXT = IT_TABDATOS-LINE+OFF(LONG).

ENDIF.

IDFLD = IDFLD + 1.

CASE IDFLD.

WHEN 1. L_TABCAMPOS-FECHA = L_TEXT.

WHEN 2. L_TABCAMPOS-SEMANO = L_TEXT.

WHEN 3. L_TABCAMPOS-SEMANA = L_TEXT.

WHEN 4. L_TABCAMPOS-DEPTO = L_TEXT.

WHEN 5. L_TABCAMPOS-TIENDA = L_TEXT.

WHEN 6. L_TABCAMPOS-ARTICULO = L_TEXT.

WHEN 7. L_TABCAMPOS-IMPORTEACT = L_TEXT.

WHEN 8. L_TABCAMPOS-IMPORTEANT = L_TEXT.

WHEN 9. L_TABCAMPOS-VOLVENACT = L_TEXT.

WHEN 10. L_TABCAMPOS-VOLVENANT = L_TEXT.

ENDCASE.

OFF = MOFF + MLEN.

ENDIF.

ENDWHILE.

IF L_TABCAMPOS IS NOT INITIAL.

L_TABCAMPOS-UNIVTA = IT_TABDATOS-LINE+OFF(3).

APPEND L_TABCAMPOS TO IT_TABCAMPOS.

ENDIF.

V_CON = V_CON + 1.

ENDLOOP.

PERFORM MENSAJE_LOG USING: 1 'Registros Procesados:', 0 V_CON.

PERFORM MENSAJE_LOG USING: 0 'Insertando en Tabla ZTVTASCANNER'.

CLEAR V_CON.

CLEAR L_TABCAMANT.

SORT IT_TABCAMPOS BY TIENDA DEPTO ARTICULO FECHA SEMANO SEMANA UNIVTA.

DATA T_ZTVTASCANNER LIKE TABLE OF ZTVTASCANNER WITH HEADER LINE.

LOOP AT IT_TABCAMPOS INTO L_TABCAMPOS.

IF L_TABCAMANT-TIENDA = L_TABCAMPOS-TIENDA

AND L_TABCAMANT-DEPTO = L_TABCAMPOS-DEPTO

AND L_TABCAMANT-ARTICULO = L_TABCAMPOS-ARTICULO

AND L_TABCAMANT-FECHA = L_TABCAMPOS-FECHA

AND L_TABCAMANT-SEMANO = L_TABCAMPOS-SEMANO

AND L_TABCAMANT-SEMANA = L_TABCAMPOS-SEMANA

AND L_TABCAMANT-UNIVTA = L_TABCAMPOS-UNIVTA.

CLEAR IT_LOGT.

CONCATENATE L_TABCAMPOS-TIENDA L_TABCAMPOS-DEPTO

L_TABCAMPOS-ARTICULO L_TABCAMPOS-FECHA

L_TABCAMPOS-SEMANO L_TABCAMPOS-SEMANA

L_TABCAMPOS-UNIVTA INTO IT_LOGT SEPARATED BY SPACE.

APPEND IT_LOGT.

ELSE.

MOVE-CORRESPONDING L_TABCAMPOS TO T_ZTVTASCANNER.

APPEND T_ZTVTASCANNER.

V_CON = V_CON + 1.

ENDIF.

L_TABCAMANT = L_TABCAMPOS.

ENDLOOP.

INSERT ZTVTASCANNER FROM TABLE T_ZTVTASCANNER.

COMMIT WORK AND WAIT.

PERFORM MENSAJE_LOG USING:

1 'Se insertaron:', 1 V_CON, 0 'Registros'.

ENDFORM. " F_TRATAR_TABDATOS

*&----


*

*& Form mensaje_log

*&----


*

  • Agrega una linea al log de proceso

*----


*

  • -->P_LIN Tipo de Linea

  • -->P_TEX Texto

*----


*

FORM MENSAJE_LOG USING P_LIN P_TEX.

CLEAR L_TEXT.

WRITE P_TEX TO L_TEXT LEFT-JUSTIFIED.

IF P_LIN EQ 1.

CONCATENATE L_LOG L_TEXT

INTO L_LOG SEPARATED BY SPACE.

ELSE.

DATA: V_FECN(14) TYPE N, V_FECHA(16) TYPE C,

TIME_STAMP TYPE TIMESTAMP,

TZONE TYPE TIMEZONE VALUE 'UTC'.

GET TIME.

V_FECN = SY-DATUM. "2007.12.14

V_FECN+8 = SY-UZEIT.

TIME_STAMP = V_FECN.

WRITE TIME_STAMP TO V_FECHA TIME ZONE TZONE.

CONCATENATE V_FECHA L_LOG L_TEXT

INTO L_LOG SEPARATED BY SPACE.

APPEND L_LOG TO IT_LOG.

IF SY-BATCH EQ 'X'.

MESSAGE L_LOG TYPE 'S'.

ENDIF.

CLEAR L_LOG .

ENDIF.

ENDFORM. "mensaje_log

former_member156446
Active Contributor
0 Kudos
49

[To a TR.|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/448e9790-0201-0010-dc83-92703150e63c]

[Uploading and downloading files between SAP and your desktop or SAP server|http://www.sapdevelopment.co.uk/file/file_updown.htm]