*&---------------------------------------------------------------------*
*& Report ZSL_TRANSFERENCIAS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zsl_transferencias.
TABLES: mara, makt.
DATA: BEGIN OF s_tabi,
matnr LIKE mara-matnr,
ERSDA like mara-ERSDA,
maktx LIKE makt-maktx,
END OF s_tabi,
tabi LIKE s_tabi OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN: BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
PARAMETERS: upload RADIOBUTTON GROUP 1,
download RADIOBUTTON GROUP 1.
SELECTION-SCREEN:END OF BLOCK block1.
SELECTION-SCREEN: BEGIN OF BLOCK block2 WITH FRAME TITLE text-002.
PARAMETERS: f_server(132) DEFAULT 'TESTE_SLOPES',
f_client LIKE RLGRAP-FILENAME default 'C:\TESTE\TESTE.TXT'.
SELECTION-SCREEN:END OF BLOCK block2.
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR F_CLIENT.
*&---------------------------------------------------------------------*
PERFORM F4_FILE_PC.
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR F_SERVER.
*&---------------------------------------------------------------------*
PERFORM F4_FILE_SERVER.
*&---------------------------------------------------------------------*
START-OF-SELECTION.
*&---------------------------------------------------------------------*
*clear tabi.
*refresh tabi.
IF upload = 'X'.
* bastava select a MAKT
SELECT a~matnr a~ERSDA
t~maktx
FROM mara AS a
INNER JOIN makt AS t
ON a~matnr = t~matnr
INTO TABLE tabi.
*copia para o pc
PERFORM local_save USING f_client.
*copia para o servidor
OPEN DATASET f_server FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT tabi.
TRANSFER tabi TO f_server.
ENDLOOP.
CLOSE DATASET f_server.
ELSE.
*preenche tabi
OPEN DATASET f_server FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET f_server INTO tabi.
IF sy-subrc NE 0.
EXIT.
ENDIF.
APPEND tabi.
ENDDO.
*escreve no pc
PERFORM local_save USING f_client.
ENDIF.
*&---------------------------------------------------------------------*
*& Form local_save
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->file_name text
*----------------------------------------------------------------------*
FORM local_save USING file_name.
DATA: L_FILE TYPE STRING.
L_FILE = FILE_NAME.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = L_FILE
tables
data_tab = tabi.
ENDFORM. " loc
*&---------------------------------------------------------------------*
*& Form F4_FILE_PC
*&---------------------------------------------------------------------*
form F4_FILE_PC .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'F_CLIENT'
IMPORTING
FILE_NAME = F_CLIENT .
endform. " F4_FILE_
*&---------------------------------------------------------------------*
*& Form F4_FILE_SERVER
*&---------------------------------------------------------------------*
form F4_FILE_SERVER .
DATA: l_location LIKE dxfields-location,
l_server LIKE msxxlist-name,
l_path LIKE dxfields-longpath,
l_flag LIKE dxfields-abendflag.
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
I_LOCATION_FLAG = 'A'
* I_SERVER = '?'
* I_PATH =
* FILEMASK = '*.*'
* FILEOPERATION = 'R'
IMPORTING
o_location_flag = l_location
o_server = l_server
o_path = l_path
abend_flag = l_flag
EXCEPTIONS
RFC_ERROR = 1
ERROR_WITH_GUI = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
MOVE l_path TO f_server.
endform. " F4_FILE_S
Subscrever:
Enviar feedback (Atom)
Sem comentários:
Enviar um comentário