This Program only useful to input text in text editor and read text editor ( by using table down in a code ). There are two editor in which end user input and save text .
*&---------------------------------------------------------------------*
*& Report ZTEST_C
**&---------------------------------------------------------------------*
*& Program : ZTEST_C *
*& Created by : tech.sap29@gmail.com *
*& Requester : *
*& Created on : *
*& Project : *
*& Ticket No : *
*& WIMS No : *
*& Workbenc Req:
*& *
*&---------------------------------------------------------------------*
*& Description :
*&---------------------------------------------------------------------*
*& Program Change History *
*&---------------------------------------------------------------------*
*& Date WIMS No TR# Name Description of Change*
*&---------------------------------------------------------------------*
*& *
REPORT ZTEST_C.
CONTROLS TEXT1 TYPE TABSTRIP.
DATA: LINE_LENGTH TYPE I VALUE 80,
EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
EDITOR_CONTANIER2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT,
TEXT_EDITOR1 TYPE REF TO CL_GUI_TEXTEDIT,
LG_TEXT TYPE STRING ,
SPL_TEXT TYPE STRING .
TYPES :BEGIN OF TY_STR,
MATNR TYPE MATNR ,
LVORM LIKE MARA-LVORM,
BISMT TYPE BISMT,
DISMM TYPE DISMM,
END OF TY_STR.
DATA : IT_UL_DTL TYPE TABLE OF TY_STR,
WA_UL_DTL TYPE TY_STR.
data : dirpath type STRING.
DATA : PLNO TYPE MATNR,
PATH_1 TYPE CHAR100,
PL_TEXT TYPE MAKTX,
MCODE TYPE MATNR.
DATA : it_mrp_hdr_dum TYPE TABLE OF ZPP_mrp_hdr_dum,
WA_MRP_HDR_DUM TYPE ZPP_MRP_HDR_DUM.
DATA : lt_texttab TYPE soli_tab,
lt_texttab1 TYPE soli_tab,
Clt_texttab TYPE soli_tab,
Tlt_texttab TYPE soli_tab,
Clt_texttab1 TYPE soli_tab,
Tlt_texttab1 TYPE soli_tab,
lt_tab TYPE soli_tab,
LV_TDNAME TYPE THEAD-TDNAME,
pr_string TYPE STRING,
SPL_STRING TYPE STRING.
DATA WA_LT LIKE LINE OF LT_TEXTTAB.
data : flag TYPE i VALUE 0.
*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'ZTEST_CHK'.
* SET TITLEBAR 'xxx'.
* PERFORM LONG_TEXT USING 'TEXTEDITOR' TEXT_EDITOR EDITOR_CONTAINER.
* PERFORM LONG_TEXT USING 'TEXTEDITOR1' TEXT_EDITOR1 EDITOR_CONTAINER.
ENDMODULE. " STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9001 INPUT.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'LGTEXT'.
TEXT1-ACTIVETAB = 'LGTEXT'.
PERFORM SPL_CONDITION.
WHEN 'SPCDT'.
TEXT1-ACTIVETAB = 'SPCDT'.
PERFORM LONG_TEXT_SAVE.
* PERFORM SPL_CONDITION.
* PERFORM TEXT_EDIT USING TEXT_EDITOR.
WHEN 'SAVE'.
PERFORM SPL_CONDITION.
PERFORM LONG_TEXT_SAVE.
PERFORM LONG_SAVE.
PERFORM SPL_SAVE.
if flag eq 1.
MESSAGE ' sucessfully updated ' TYPE 'I'.
ELSE.
MESSAGE 'unsecssfully updated ' TYPE 'I'.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'UPLOAD'.
PERFORM UPLOAD_DRAWING.
WHEN 'DLOAD'.
PERFORM DOWNLOAD_DRAWING .
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
*& Form LONG_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXTEDITOR text
*----------------------------------------------------------------------*
FORM LONG_TEXT USING P_TEXTEDITOR TYPE ANY
P_TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT
P_EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER .
IF P_TEXT_EDITOR IS INITIAL.
CREATE OBJECT P_EDITOR_CONTAINER
EXPORTING
CONTAINER_NAME = P_TEXTEDITOR
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
CREATE OBJECT P_TEXT_EDITOR
EXPORTING
PARENT = P_EDITOR_CONTAINER
WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
WORDWRAP_POSITION = LINE_LENGTH
WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE.
*3)HIDE TOOLBAR AND STATUSBAR
* CALL METHOD P_TEXT_EDITOR->SET_TOOLBAR_MODE
* EXPORTING
* TOOLBAR_MODE = CL_GUI_TEXTEDIT=>FALSE.
CALL METHOD P_TEXT_EDITOR->SET_STATUSBAR_MODE
EXPORTING
STATUSBAR_MODE = CL_GUI_TEXTEDIT=>FALSE.
ENDIF.
ENDFORM. " LONG_TEXT
*&---------------------------------------------------------------------*
*& Form TEXT_EDIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXT_EDITOR text
*----------------------------------------------------------------------*
FORM TEXT_EDIT USING P_TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT
VALUE TYPE ANY .
* APPEND 'alok kumar jain ' to lt_texttab.
*data lt_texttab TYPE STANDARD TABLE ltext.
IF VALUE EQ 1.
IF Clt_texttab[] IS NOT INITIAL.
REFRESH LT_TEXTTAB.
APPEND LINES OF Clt_texttab TO lt_texttab.
ENDIF.
CALL METHOD P_text_editor->set_text_as_r3table
EXPORTING
table = lt_texttab " Contents of this table is displayed in text editor
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
* PERFORM LONG_TEXT_SAVE.
ELSEIF VALUE EQ 2.
IF Clt_texttab1[] IS NOT INITIAL.
REFRESH LT_TEXTTAB1.
APPEND LINES OF Clt_texttab1 TO lt_texttab1.
ENDIF.
CALL METHOD P_text_editor->set_text_as_r3table
EXPORTING
table = lt_texttab1 " Contents of this table is displayed in text editor
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
*
* MESSAGE TEXT TYPE 'I'.
ENDFORM. " TEXT_EDIT
*&SPWIZARD: DECLARATION OF TABLECONTROL 'ZTEST' ITSELF
CONTROLS: ZTEST TYPE TABLEVIEW USING SCREEN 9001.
*&SPWIZARD: OUTPUT MODULE FOR TC 'ZTEST'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
MODULE ZTEST_CHANGE_TC_ATTR OUTPUT.
DESCRIBE TABLE IT_UL_DTL LINES ZTEST-lines.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9002 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9002 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
PERFORM LONG_TEXT USING 'TEXTEDITOR' TEXT_EDITOR EDITOR_CONTAINER.
ENDMODULE. " STATUS_9002 OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_9003 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9003 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
PERFORM LONG_TEXT USING 'TEXTEDITOR1' TEXT_EDITOR1 EDITOR_CONTAINER.
ENDMODULE. " STATUS_9003 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9003 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9003 INPUT.
PERFORM TEXT_EDIT USING TEXT_EDITOR1 2.
ENDMODULE. " USER_COMMAND_9003 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9002 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9002 INPUT.
PERFORM TEXT_EDIT USING TEXT_EDITOR 1.
ENDMODULE. " USER_COMMAND_9002 INPUT
*&---------------------------------------------------------------------*
*& Module HELP INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE HELP INPUT.
DATA : P_NAME TYPE RLGRAP-FILENAME.
CONSTANTS: C_DEF_FILENAME TYPE CHAR1 VALUE '*',
C_MASK TYPE CHAR5 VALUE '*.txt'.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = C_DEF_FILENAME
MASK = C_MASK
TITLE = TEXT-002
IMPORTING
FILENAME = DIRPATH
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDMODULE. " HELP INPUT
*&---------------------------------------------------------------------*
*& Module GET_PL OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE GET_PL OUTPUT.
IF SY-TCODE EQ 'ZCHK'.
GET PARAMETER ID 'MAT' FIELD PLNO.
GET PARAMETER ID 'PATH_1' FIELD PATH_1.
IF PLNO IS NOT INITIAL.
CONCATENATE '______' PLNO '____' INTO MCODE.
SELECT SINGLE MAKTX FROM MAKT INTO PL_TEXT
WHERE MATNR LIKE MCODE.
SELECT B~MATNR A~LVORM BISMT DISMM
FROM MARC AS A
INNER JOIN MARA AS B ON B~MATNR = A~MATNR
INTO TABLE IT_UL_DTL
WHERE B~MATNR LIKE MCODE.
IF SY-SUBRC EQ 0 .
SORT IT_UL_DTL ASCENDING BY MATNR .
DELETE ADJACENT DUPLICATES FROM IT_UL_DTL.
ENDIF.
ENDIF.
ENDIF.
ENDMODULE. " GET_PL OUTPUT
*&---------------------------------------------------------------------*
*& Form UPLOAD_DRAWING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_DRAWING .
DATA: GT_RAW_DATA TYPE TABLE OF X255,
GV_FIL_LEN TYPE I.
DATA: LT_TAB TYPE SWXMLCONT,
LS_TAB TYPE X255,
LV_ZIP_FILE TYPE c LENGTH 255.
* LV_ZIP_FILE(255) VALUE '//zicf//PP/sap2win/prodprog/filersd.zip'.
* BREAK-POINT.
* //logfile
TYPES : BEGIN OF TY_ITAB,
UNAME TYPE SY-UNAME,
ZDATE TYPE SY-DATUM,
TYP(10) TYPE C,
FILENAME(100) TYPE C,
END OF TY_ITAB.
DATA : ITAB TYPE TABLE OF ZFILEDBASE WITH HEADER LINE,
ITAB1 TYPE TABLE OF ZFILEDBASE WITH HEADER LINE,
WA_ITAB TYPE ZFILEDBASE, "ty_itab.
WA_ITAB1 TYPE ZFILEDBASE, "ty_itab.
WA_ITAB2 TYPE ZFILEDBASE. "ty_itab.
DATA: temp TYPE STRING,
TEMP2 TYPE MATNR .
* BREAK-POINT.
if dirpath is NOT INITIAL.
CONCATENATE '//zicf//PP/sap2win/prodprog/'sy-DATUM'_'sy-UZEIT'_'plno'.zip' INTO TEMP.
* DATA: LV_ZIP_FILE TYPE STRING.
WA_ITAB-UNAME = SY-UNAME.
WA_ITAB-ZDATE = SY-DATUM.
WA_ITAB-Ztime = SY-UZEIT.
WA_ITAB-plno = plno.
WA_ITAB-TYP = 'upload'.
WA_ITAB-FILENAME = temp."changes made vinodh sse/icf
* WA_ITAB-FILENAME = '//zicf//PP/sap2win/prodprog/filersd.zip'.
APPEND WA_ITAB TO ITAB.
* clear itab.
* Loop at itab into wa_itab.
MODIFY ZFILEDBASE FROM WA_ITAB.
CONCATENATE '______' PLNO '____' INTO TEMP2.
SELECT * FROM zpp_mrp_hdr_dum INTO TABLE it_mrp_hdr_dum WHERE matnr like temp2.
if it_mrp_hdr_dum IS NOT INITIAL .
LOOP at it_mrp_hdr_dum INTO wa_mrp_hdr_dum.
wa_mrp_hdr_dum-FILEPATH = wa_ITAB-FILENAME.
MODIFY zpp_mrp_hdr_dum FROM wa_mrp_hdr_dum.
COMMIT WORK.
ENDLOOP.
ENDIF.
* endloop.
LV_ZIP_FILE = temp.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD(
EXPORTING
FILENAME = DIRPATH
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = GV_FIL_LEN
CHANGING
DATA_TAB = GT_RAW_DATA
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
NOT_SUPPORTED_BY_GUI = 17
ERROR_NO_GUI = 18
OTHERS = 19
).
IF SY-SUBRC = 0.
OPEN DATASET LV_ZIP_FILE FOR OUTPUT IN BINARY MODE.
LOOP AT GT_RAW_DATA INTO LS_TAB.
TRANSFER LS_TAB TO LV_ZIP_FILE.
ENDLOOP.
CLOSE DATASET LV_ZIP_FILE.
MESSAGE 'SUCESSFULLY UPLOADED FILE' TYPE 'I'.
ENDIF.
ELSE.
MESSAGE 'GIVE DRAWING PATH PROPERLY' TYPE 'E'.
ENDIF.
ENDFORM. " UPLOAD_DRAWING
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_DRAWING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DOWNLOAD_DRAWING .
DATA: LT_TAB TYPE SWXMLCONT,
LS_TAB TYPE X255,
LV_ZIP_FILE TYPE C LENGTH 255.
DATA : PATH TYPE STRING.
DATA: TEMP1 TYPE STRING.
DATA: TEMP2 TYPE STRING.
DATA : ITAB TYPE TABLE OF ZFILEDBASE WITH HEADER LINE,
ITAB1 TYPE TABLE OF ZFILEDBASE WITH HEADER LINE,
WA_ITAB TYPE ZFILEDBASE, "ty_itab.
WA_ITAB1 TYPE ZFILEDBASE,
WA_ITAB2 TYPE ZFILEDBASE. "ty_itab.
* BREAK-POINT.
SELECT * FROM ZFILEDBASE INTO TABLE ITAB1 WHERE PLNO = PLNO AND TYP = 'upload'.
* IF PL_TEXT NE ' '.
if itab1[] is NOT INITIAL.
SORT ITAB1 DESCENDING BY PLNO ZDATE ZTIME.
READ TABLE ITAB1 INTO WA_ITAB1 INDEX 1.
CONCATENATE SY-DATUM'_'SY-UZEIT'_'plno'.zip' INTO TEMP1.
* CONCATENATE '//zicf//PP/sap2win/prodprog/'plno'.zip' INTO TEMP1.
WA_ITAB2-UNAME = SY-UNAME.
WA_ITAB2-ZDATE = SY-DATUM.
WA_ITAB2-TYP = 'Download'.
WA_ITAB2-FILENAME = WA_ITAB1-FILENAME."changes made by vinodh sse/icf
* WA_ITAB-FILENAME = '//zicf//PP/sap2win/prodprog/filersd.zip'.
APPEND WA_ITAB TO ITAB.
LV_ZIP_FILE = WA_ITAB2-FILENAME.
* LV_ZIP_FILE = temp1.
MODIFY ZFILEDBASE FROM WA_ITAB2.
DATA: INFO TYPE TABLE OF ORBLK,
WA_INFO TYPE ORBLK,
LN LIKE SY-TABIX,
LN_SIZE TYPE I,
L_W_FILENAME TYPE STRING,
LV(4) TYPE N.
DATA : DSN TYPE STRING.
DSN = LV_ZIP_FILE .
OPEN DATASET DSN FOR INPUT IN BINARY MODE.
IF SY-SUBRC = 0.
CLEAR: LN_SIZE,INFO[],WA_INFO.
DO .
CLEAR: LN,WA_INFO.
READ DATASET DSN INTO WA_INFO LENGTH LN.
IF SY-SUBRC <> 0.
IF LN > 0.
LN_SIZE = LN_SIZE + LN.
APPEND WA_INFO TO INFO.
ENDIF.
EXIT.
ENDIF.
LN_SIZE = LN_SIZE + LN.
APPEND WA_INFO TO INFO.
ENDDO.
CLOSE DATASET DSN.
ENDIF.
CONCATENATE 'C:\ERP_DRGS\'TEMP1 INTO TEMP2.
path = TEMP2.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = LN_SIZE
FILENAME = PATH
FILETYPE = 'BIN'
TABLES
DATA_TAB = INFO
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC EQ 0.
MESSAGE 'SUCESSFULLY TRASFERED ' TYPE 'I'.
endif.
ELSE.
MESSAGE 'FILE NOT EXISTING ' TYPE 'E'.
ENDIF.
ENDFORM. " DOWNLOAD_DRAWING
*&---------------------------------------------------------------------*
*& Module LONG_TEXT OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE LONG_TEXT OUTPUT.
READ TABLE it_ul_dtl INTO wa_ul_dtl INDEX 1.
DATA: BEGIN OF LTEXT OCCURS 100.
INCLUDE STRUCTURE TLINE.
DATA : END OF LTEXT.
REFRESH :LTEXT , lt_texttab .
TYPES: BEGIN OF TY_POTEXT,
POTEXT LIKE ZMM_PLHISTN-DESCRIPTION,
" PL_NO LIKE ZMM_PLHISTN-PL_NO,
" SL_NO LIKE ZMM_PLHISTN-SL_NO,
END OF TY_POTEXT.
DATA : IT_POTEXT TYPE TABLE OF TY_POTEXT WITH HEADER LINE,
WA_POTEXT LIKE LINE OF IT_POTEXT.
if wa_ul_dtl IS NOT INITIAL .
MOVE wa_ul_dtl-MATNR TO LV_TDNAME.
*if clt_texttab[] is INITIAL .
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = 'BEST'
LANGUAGE = 'E'
NAME = LV_TDNAME
OBJECT = 'MATERIAL'
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
IF SY-SUBRC EQ 0.
CLEAR pr_string.
LOOP AT LTEXT .
WA_POTEXT-POTEXT = LTEXT-TDLINE.
APPEND WA_POTEXT TO lt_texttab .
CONCATENATE pr_string WA_POTEXT INTO PR_STRING .
ENDLOOP.
ENDIF.
ENDIF.
*ELSE.
* APPEND LINES OF clt_texttab to lt_texttab.
*ENDIF .
ENDMODULE. " LONG_TEXT OUTPUT
*&---------------------------------------------------------------------*
*& Module SPL_CONDITION OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE SPL_CONDITION OUTPUT.
CLEAR : LV_TDNAME,WA_POTEXT.
CLEAR SPL_STRING.
REFRESH : LTEXT ,lt_texttab1 .
READ TABLE it_ul_dtl INTO wa_ul_dtl INDEX 1.
IF WA_UL_DTL IS NOT INITIAL .
CONCATENATE WA_ul_dtl-MATNR 'ICFRIC' INTO LV_TDNAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = '0001'
LANGUAGE = 'E'
NAME = LV_TDNAME
OBJECT = 'MVKE'
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
IF SY-SUBRC EQ 0.
LOOP AT LTEXT .
WA_POTEXT-POTEXT = LTEXT-TDLINE.
CONCATENATE SPL_STRING WA_POTEXT INTO SPL_STRING .
APPEND WA_POTEXT TO lt_texttab1 .
ENDLOOP.
ENDIF.
ENDIF.
ENDMODULE. " SPL_CONDITION OUTPUT
*&---------------------------------------------------------------------*
*& Form LONG_TEXT_SAVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LONG_TEXT_SAVE .
FIELD-SYMBOLS <text_string> TYPE ANY .
DATA: text_string TYPE soli_tab,
modify type i value 1.
REFRESH Tlt_texttab.
CLEAR : LG_TEXT ,SPL_TEXT, TEXT_STRING.
APPEND LINES OF clt_texttab TO Tlt_texttab.
CALL METHOD TEXT_EDITOR->GET_TEXT_AS_R3TABLE
EXPORTING
ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE
IMPORTING
TABLE = clt_texttab
IS_MODIFIED = modify
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
ERROR_DP_CREATE = 3
POTENTIAL_DATA_LOSS = 4
others = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
if modify eq 0 .
APPEND LINES OF Tlt_texttab TO clt_texttab.
endif.
ENDIF.
*
*
* CALL METHOD CL_GUI_CFW=>FLUSH
* EXCEPTIONS
* CNTL_SYSTEM_ERROR = 1
* CNTL_ERROR = 2
* OTHERS = 3.
ENDFORM. " LONG_TEXT_SAVE
*&---------------------------------------------------------------------*
*& Form SPL_CONDITION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SPL_CONDITION .
DATA: text_string1 TYPE soli_tab,
modify type i value 1.
REFRESH Tlt_texttab1 .
APPEND LINES OF Clt_texttab1 TO Tlt_texttab1 .
CALL METHOD TEXT_EDITOR1->GET_TEXT_AS_R3TABLE
EXPORTING
ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE
IMPORTING
TABLE = clt_texttab1
IS_MODIFIED = modify
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
ERROR_DP_CREATE = 3
POTENTIAL_DATA_LOSS = 4
others = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
if modify eq 0 .
APPEND LINES OF Tlt_texttab1 TO Clt_texttab1 .
endif.
ENDIF.
ENDFORM. " SPL_CONDITION
*&---------------------------------------------------------------------*
*& Form LONG_SAVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LONG_SAVE .
DATA WA_LT LIKE LINE OF LT_TEXTTAB.
IF Clt_texttab IS NOT INITIAL.
flag = 1.
REFRESH lt_texttab.
APPEND LINES OF Clt_texttab TO lt_texttab.
PERFORM LOG_FILE.
PERFORM update_long_text.
ENDIF.
READ TABLE lt_texttab INTO WA_LT INDEX 1.
ENDFORM. " LONG_SAVE
*&---------------------------------------------------------------------*
*& Form SPL_SAVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SPL_SAVE .
IF Clt_texttab1 IS NOT INITIAL.
REFRESH lt_texttab1.
flag = 1.
APPEND LINES OF Clt_texttab1 TO lt_texttab1.
PERFORM log_file_spl_condition .
PERFORM SAVE_SPL_SCONDITION .
ENDIF.
READ TABLE lt_texttab1 INTO WA_LT INDEX 1.
ENDFORM. " SPL_SAVE
*&---------------------------------------------------------------------*
*& Form LOG_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LOG_FILE .
DATA : IT_PLHIST TYPE STANDARD TABLE OF ZMM_PLHISTN ,
WA_PLHIST LIKE LINE OF IT_PLHIST.
DATA : PR_KEY LIKE ZMM_PLHISTN-TEMP_SLNO,
VER_NO LIKE ZMM_PLHISTN-VER_NO,
sr_num TYPE i.
data : pl_num TYPE char8.
pl_num = plno.
SELECT SINGLE MAX( TEMP_SLNO ) FROM ZMM_PLHISTN INTO PR_KEY.
SELECT SINGLE MAX( VER_NO ) FROM ZMM_PLHISTN INTO VER_NO WHERE PL_NO = PL_num.
ver_no = ver_no + 1.
sr_num = pr_key.
LOOP AT LT_TEXTTAB INTO WA_LT.
sr_num = sr_num + 1.
WA_PLHIST-TEMP_SLNO = sr_num.
WA_PLHIST-PL_NO = PL_num.
WA_PLHIST-DATE_CREATED = SY-DATUM.
WA_PLHIST-TIME_CREATED = SY-UZEIT.
WA_PLHIST-USER_CREATED = SY-UNAME.
WA_PLHIST-VER_NO = VER_NO.
WA_PLHIST-DESCRIPTION = wa_lt-line.
APPEND WA_PLHIST to IT_PLHIST .
CLEAR : WA_PLHIST,wa_lt.
ENDLOOP.
MODIFY ZMM_PLHISTN FROM TABLE IT_PLHIST.
COMMIT WORK.
ENDFORM. " LOG_FILE
*&---------------------------------------------------------------------*
*& Form LOG_FILE_SPL_CONDITION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LOG_FILE_SPL_CONDITION .
CLEAR wa_lt.
DATA : IT_PLHIST TYPE STANDARD TABLE OF ZMM_PLHISTN ,
WA_PLHIST LIKE LINE OF IT_PLHIST.
DATA : PR_KEY LIKE ZMM_PLHISTN-TEMP_SLNO,
VER_NO LIKE ZMM_PLHISTN-VER_NO,
sr_num TYPE i.
data : pl_num TYPE char8.
pl_num = plno.
SELECT SINGLE MAX( TEMP_SLNO ) FROM ZMM_PLHISTN INTO PR_KEY.
SELECT SINGLE MAX( VER_NO ) FROM ZMM_PLHISTN INTO VER_NO WHERE PL_NO = PL_num.
ver_no = ver_no + 1.
sr_num = pr_key.
LOOP AT LT_TEXTTAB1 INTO WA_LT.
sr_num = sr_num + 1.
WA_PLHIST-TEMP_SLNO = sr_num.
WA_PLHIST-PL_NO = PL_num.
WA_PLHIST-DATE_CREATED = SY-DATUM.
WA_PLHIST-TIME_CREATED = SY-UZEIT.
WA_PLHIST-USER_CREATED = SY-UNAME.
WA_PLHIST-VER_NO = VER_NO.
WA_PLHIST-SPL_CONDITION = wa_lt-line.
APPEND WA_PLHIST to IT_PLHIST .
CLEAR : WA_PLHIST,wa_lt.
ENDLOOP.
MODIFY ZMM_PLHISTN FROM TABLE IT_PLHIST.
COMMIT WORK.
ENDFORM. " LOG_FILE_SPL_CONDITION
*&---------------------------------------------------------------------*
*& Form UPDATE_LONG_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPDATE_LONG_TEXT .
DATA: T_FLINES TYPE STANDARD TABLE OF TLINE WITH HEADER LINE,
WA_TLINE TYPE TLINE.
CLEAR LV_TDNAME.
REFRESH T_FLINES.
LOOP AT LT_TEXTTAB INTO WA_LT.
WA_TLINE-TDLINE = SY-TABIX.
T_FLINES-TDLINE = wa_lt-line.
APPEND T_FLINES.
CLEAR T_FLINES-TDLINE.
ENDLOOP.
LOOP AT IT_UL_DTL INTO WA_UL_DTL.
MOVE WA_UL_DTL-MATNR TO LV_TDNAME.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
FID = 'BEST'
FLANGUAGE = SY-LANGU
FNAME = LV_TDNAME
FOBJECT = 'MATERIAL'
SAVE_DIRECT = 'X'
FFORMAT = ' '
TABLES
FLINES = T_FLINES.
ENDLOOP.
ENDFORM. " UPDATE_LONG_TEXT
*&---------------------------------------------------------------------*
*& Form SAVE_SPL_SCONDITION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SAVE_SPL_SCONDITION .
DATA: T_FLINES TYPE STANDARD TABLE OF TLINE WITH HEADER LINE,
WA_TLINE TYPE TLINE.
CLEAR LV_TDNAME.
REFRESH T_FLINES.
LOOP AT LT_TEXTTAB1 INTO WA_LT.
WA_TLINE-TDLINE = SY-TABIX.
T_FLINES-TDLINE = wa_lt-line.
APPEND T_FLINES.
CLEAR T_FLINES-TDLINE.
ENDLOOP.
LOOP AT IT_UL_DTL INTO WA_UL_DTL.
CONCATENATE WA_UL_DTL-MATNR 'ICFRIC' INTO LV_TDNAME.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
FID = '0001'
FLANGUAGE = SY-LANGU
FNAME = LV_TDNAME
FOBJECT = 'MVKE'
SAVE_DIRECT = 'X'
FFORMAT = ' '
TABLES
FLINES = T_FLINES.
ENDLOOP.
ENDFORM. " SAVE_SPL_SCONDITION
*&---------------------------------------------------------------------*
*& Report ZTEST_C
**&---------------------------------------------------------------------*
*& Program : ZTEST_C *
*& Created by : tech.sap29@gmail.com *
*& Requester : *
*& Created on : *
*& Project : *
*& Ticket No : *
*& WIMS No : *
*& Workbenc Req:
*& *
*&---------------------------------------------------------------------*
*& Description :
*&---------------------------------------------------------------------*
*& Program Change History *
*&---------------------------------------------------------------------*
*& Date WIMS No TR# Name Description of Change*
*&---------------------------------------------------------------------*
*& *
REPORT ZTEST_C.
CONTROLS TEXT1 TYPE TABSTRIP.
DATA: LINE_LENGTH TYPE I VALUE 80,
EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
EDITOR_CONTANIER2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT,
TEXT_EDITOR1 TYPE REF TO CL_GUI_TEXTEDIT,
LG_TEXT TYPE STRING ,
SPL_TEXT TYPE STRING .
TYPES :BEGIN OF TY_STR,
MATNR TYPE MATNR ,
LVORM LIKE MARA-LVORM,
BISMT TYPE BISMT,
DISMM TYPE DISMM,
END OF TY_STR.
DATA : IT_UL_DTL TYPE TABLE OF TY_STR,
WA_UL_DTL TYPE TY_STR.
data : dirpath type STRING.
DATA : PLNO TYPE MATNR,
PATH_1 TYPE CHAR100,
PL_TEXT TYPE MAKTX,
MCODE TYPE MATNR.
DATA : it_mrp_hdr_dum TYPE TABLE OF ZPP_mrp_hdr_dum,
WA_MRP_HDR_DUM TYPE ZPP_MRP_HDR_DUM.
DATA : lt_texttab TYPE soli_tab,
lt_texttab1 TYPE soli_tab,
Clt_texttab TYPE soli_tab,
Tlt_texttab TYPE soli_tab,
Clt_texttab1 TYPE soli_tab,
Tlt_texttab1 TYPE soli_tab,
lt_tab TYPE soli_tab,
LV_TDNAME TYPE THEAD-TDNAME,
pr_string TYPE STRING,
SPL_STRING TYPE STRING.
DATA WA_LT LIKE LINE OF LT_TEXTTAB.
data : flag TYPE i VALUE 0.
*&---------------------------------------------------------------------*
*& Module STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'ZTEST_CHK'.
* SET TITLEBAR 'xxx'.
* PERFORM LONG_TEXT USING 'TEXTEDITOR' TEXT_EDITOR EDITOR_CONTAINER.
* PERFORM LONG_TEXT USING 'TEXTEDITOR1' TEXT_EDITOR1 EDITOR_CONTAINER.
ENDMODULE. " STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9001 INPUT.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'LGTEXT'.
TEXT1-ACTIVETAB = 'LGTEXT'.
PERFORM SPL_CONDITION.
WHEN 'SPCDT'.
TEXT1-ACTIVETAB = 'SPCDT'.
PERFORM LONG_TEXT_SAVE.
* PERFORM SPL_CONDITION.
* PERFORM TEXT_EDIT USING TEXT_EDITOR.
WHEN 'SAVE'.
PERFORM SPL_CONDITION.
PERFORM LONG_TEXT_SAVE.
PERFORM LONG_SAVE.
PERFORM SPL_SAVE.
if flag eq 1.
MESSAGE ' sucessfully updated ' TYPE 'I'.
ELSE.
MESSAGE 'unsecssfully updated ' TYPE 'I'.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'UPLOAD'.
PERFORM UPLOAD_DRAWING.
WHEN 'DLOAD'.
PERFORM DOWNLOAD_DRAWING .
ENDCASE.
ENDMODULE. " USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
*& Form LONG_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXTEDITOR text
*----------------------------------------------------------------------*
FORM LONG_TEXT USING P_TEXTEDITOR TYPE ANY
P_TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT
P_EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER .
IF P_TEXT_EDITOR IS INITIAL.
CREATE OBJECT P_EDITOR_CONTAINER
EXPORTING
CONTAINER_NAME = P_TEXTEDITOR
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
CREATE OBJECT P_TEXT_EDITOR
EXPORTING
PARENT = P_EDITOR_CONTAINER
WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
WORDWRAP_POSITION = LINE_LENGTH
WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE.
*3)HIDE TOOLBAR AND STATUSBAR
* CALL METHOD P_TEXT_EDITOR->SET_TOOLBAR_MODE
* EXPORTING
* TOOLBAR_MODE = CL_GUI_TEXTEDIT=>FALSE.
CALL METHOD P_TEXT_EDITOR->SET_STATUSBAR_MODE
EXPORTING
STATUSBAR_MODE = CL_GUI_TEXTEDIT=>FALSE.
ENDIF.
ENDFORM. " LONG_TEXT
*&---------------------------------------------------------------------*
*& Form TEXT_EDIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXT_EDITOR text
*----------------------------------------------------------------------*
FORM TEXT_EDIT USING P_TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT
VALUE TYPE ANY .
* APPEND 'alok kumar jain ' to lt_texttab.
*data lt_texttab TYPE STANDARD TABLE ltext.
IF VALUE EQ 1.
IF Clt_texttab[] IS NOT INITIAL.
REFRESH LT_TEXTTAB.
APPEND LINES OF Clt_texttab TO lt_texttab.
ENDIF.
CALL METHOD P_text_editor->set_text_as_r3table
EXPORTING
table = lt_texttab " Contents of this table is displayed in text editor
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
* PERFORM LONG_TEXT_SAVE.
ELSEIF VALUE EQ 2.
IF Clt_texttab1[] IS NOT INITIAL.
REFRESH LT_TEXTTAB1.
APPEND LINES OF Clt_texttab1 TO lt_texttab1.
ENDIF.
CALL METHOD P_text_editor->set_text_as_r3table
EXPORTING
table = lt_texttab1 " Contents of this table is displayed in text editor
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
*
* MESSAGE TEXT TYPE 'I'.
ENDFORM. " TEXT_EDIT
*&SPWIZARD: DECLARATION OF TABLECONTROL 'ZTEST' ITSELF
CONTROLS: ZTEST TYPE TABLEVIEW USING SCREEN 9001.
*&SPWIZARD: OUTPUT MODULE FOR TC 'ZTEST'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
MODULE ZTEST_CHANGE_TC_ATTR OUTPUT.
DESCRIBE TABLE IT_UL_DTL LINES ZTEST-lines.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9002 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9002 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
PERFORM LONG_TEXT USING 'TEXTEDITOR' TEXT_EDITOR EDITOR_CONTAINER.
ENDMODULE. " STATUS_9002 OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_9003 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_9003 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
PERFORM LONG_TEXT USING 'TEXTEDITOR1' TEXT_EDITOR1 EDITOR_CONTAINER.
ENDMODULE. " STATUS_9003 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9003 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9003 INPUT.
PERFORM TEXT_EDIT USING TEXT_EDITOR1 2.
ENDMODULE. " USER_COMMAND_9003 INPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9002 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_9002 INPUT.
PERFORM TEXT_EDIT USING TEXT_EDITOR 1.
ENDMODULE. " USER_COMMAND_9002 INPUT
*&---------------------------------------------------------------------*
*& Module HELP INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE HELP INPUT.
DATA : P_NAME TYPE RLGRAP-FILENAME.
CONSTANTS: C_DEF_FILENAME TYPE CHAR1 VALUE '*',
C_MASK TYPE CHAR5 VALUE '*.txt'.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = C_DEF_FILENAME
MASK = C_MASK
TITLE = TEXT-002
IMPORTING
FILENAME = DIRPATH
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDMODULE. " HELP INPUT
*&---------------------------------------------------------------------*
*& Module GET_PL OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE GET_PL OUTPUT.
IF SY-TCODE EQ 'ZCHK'.
GET PARAMETER ID 'MAT' FIELD PLNO.
GET PARAMETER ID 'PATH_1' FIELD PATH_1.
IF PLNO IS NOT INITIAL.
CONCATENATE '______' PLNO '____' INTO MCODE.
SELECT SINGLE MAKTX FROM MAKT INTO PL_TEXT
WHERE MATNR LIKE MCODE.
SELECT B~MATNR A~LVORM BISMT DISMM
FROM MARC AS A
INNER JOIN MARA AS B ON B~MATNR = A~MATNR
INTO TABLE IT_UL_DTL
WHERE B~MATNR LIKE MCODE.
IF SY-SUBRC EQ 0 .
SORT IT_UL_DTL ASCENDING BY MATNR .
DELETE ADJACENT DUPLICATES FROM IT_UL_DTL.
ENDIF.
ENDIF.
ENDIF.
ENDMODULE. " GET_PL OUTPUT
*&---------------------------------------------------------------------*
*& Form UPLOAD_DRAWING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_DRAWING .
DATA: GT_RAW_DATA TYPE TABLE OF X255,
GV_FIL_LEN TYPE I.
DATA: LT_TAB TYPE SWXMLCONT,
LS_TAB TYPE X255,
LV_ZIP_FILE TYPE c LENGTH 255.
* LV_ZIP_FILE(255) VALUE '//zicf//PP/sap2win/prodprog/filersd.zip'.
* BREAK-POINT.
* //logfile
TYPES : BEGIN OF TY_ITAB,
UNAME TYPE SY-UNAME,
ZDATE TYPE SY-DATUM,
TYP(10) TYPE C,
FILENAME(100) TYPE C,
END OF TY_ITAB.
DATA : ITAB TYPE TABLE OF ZFILEDBASE WITH HEADER LINE,
ITAB1 TYPE TABLE OF ZFILEDBASE WITH HEADER LINE,
WA_ITAB TYPE ZFILEDBASE, "ty_itab.
WA_ITAB1 TYPE ZFILEDBASE, "ty_itab.
WA_ITAB2 TYPE ZFILEDBASE. "ty_itab.
DATA: temp TYPE STRING,
TEMP2 TYPE MATNR .
* BREAK-POINT.
if dirpath is NOT INITIAL.
CONCATENATE '//zicf//PP/sap2win/prodprog/'sy-DATUM'_'sy-UZEIT'_'plno'.zip' INTO TEMP.
* DATA: LV_ZIP_FILE TYPE STRING.
WA_ITAB-UNAME = SY-UNAME.
WA_ITAB-ZDATE = SY-DATUM.
WA_ITAB-Ztime = SY-UZEIT.
WA_ITAB-plno = plno.
WA_ITAB-TYP = 'upload'.
WA_ITAB-FILENAME = temp."changes made vinodh sse/icf
* WA_ITAB-FILENAME = '//zicf//PP/sap2win/prodprog/filersd.zip'.
APPEND WA_ITAB TO ITAB.
* clear itab.
* Loop at itab into wa_itab.
MODIFY ZFILEDBASE FROM WA_ITAB.
CONCATENATE '______' PLNO '____' INTO TEMP2.
SELECT * FROM zpp_mrp_hdr_dum INTO TABLE it_mrp_hdr_dum WHERE matnr like temp2.
if it_mrp_hdr_dum IS NOT INITIAL .
LOOP at it_mrp_hdr_dum INTO wa_mrp_hdr_dum.
wa_mrp_hdr_dum-FILEPATH = wa_ITAB-FILENAME.
MODIFY zpp_mrp_hdr_dum FROM wa_mrp_hdr_dum.
COMMIT WORK.
ENDLOOP.
ENDIF.
* endloop.
LV_ZIP_FILE = temp.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD(
EXPORTING
FILENAME = DIRPATH
FILETYPE = 'BIN'
IMPORTING
FILELENGTH = GV_FIL_LEN
CHANGING
DATA_TAB = GT_RAW_DATA
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
NOT_SUPPORTED_BY_GUI = 17
ERROR_NO_GUI = 18
OTHERS = 19
).
IF SY-SUBRC = 0.
OPEN DATASET LV_ZIP_FILE FOR OUTPUT IN BINARY MODE.
LOOP AT GT_RAW_DATA INTO LS_TAB.
TRANSFER LS_TAB TO LV_ZIP_FILE.
ENDLOOP.
CLOSE DATASET LV_ZIP_FILE.
MESSAGE 'SUCESSFULLY UPLOADED FILE' TYPE 'I'.
ENDIF.
ELSE.
MESSAGE 'GIVE DRAWING PATH PROPERLY' TYPE 'E'.
ENDIF.
ENDFORM. " UPLOAD_DRAWING
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_DRAWING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DOWNLOAD_DRAWING .
DATA: LT_TAB TYPE SWXMLCONT,
LS_TAB TYPE X255,
LV_ZIP_FILE TYPE C LENGTH 255.
DATA : PATH TYPE STRING.
DATA: TEMP1 TYPE STRING.
DATA: TEMP2 TYPE STRING.
DATA : ITAB TYPE TABLE OF ZFILEDBASE WITH HEADER LINE,
ITAB1 TYPE TABLE OF ZFILEDBASE WITH HEADER LINE,
WA_ITAB TYPE ZFILEDBASE, "ty_itab.
WA_ITAB1 TYPE ZFILEDBASE,
WA_ITAB2 TYPE ZFILEDBASE. "ty_itab.
* BREAK-POINT.
SELECT * FROM ZFILEDBASE INTO TABLE ITAB1 WHERE PLNO = PLNO AND TYP = 'upload'.
* IF PL_TEXT NE ' '.
if itab1[] is NOT INITIAL.
SORT ITAB1 DESCENDING BY PLNO ZDATE ZTIME.
READ TABLE ITAB1 INTO WA_ITAB1 INDEX 1.
CONCATENATE SY-DATUM'_'SY-UZEIT'_'plno'.zip' INTO TEMP1.
* CONCATENATE '//zicf//PP/sap2win/prodprog/'plno'.zip' INTO TEMP1.
WA_ITAB2-UNAME = SY-UNAME.
WA_ITAB2-ZDATE = SY-DATUM.
WA_ITAB2-TYP = 'Download'.
WA_ITAB2-FILENAME = WA_ITAB1-FILENAME."changes made by vinodh sse/icf
* WA_ITAB-FILENAME = '//zicf//PP/sap2win/prodprog/filersd.zip'.
APPEND WA_ITAB TO ITAB.
LV_ZIP_FILE = WA_ITAB2-FILENAME.
* LV_ZIP_FILE = temp1.
MODIFY ZFILEDBASE FROM WA_ITAB2.
DATA: INFO TYPE TABLE OF ORBLK,
WA_INFO TYPE ORBLK,
LN LIKE SY-TABIX,
LN_SIZE TYPE I,
L_W_FILENAME TYPE STRING,
LV(4) TYPE N.
DATA : DSN TYPE STRING.
DSN = LV_ZIP_FILE .
OPEN DATASET DSN FOR INPUT IN BINARY MODE.
IF SY-SUBRC = 0.
CLEAR: LN_SIZE,INFO[],WA_INFO.
DO .
CLEAR: LN,WA_INFO.
READ DATASET DSN INTO WA_INFO LENGTH LN.
IF SY-SUBRC <> 0.
IF LN > 0.
LN_SIZE = LN_SIZE + LN.
APPEND WA_INFO TO INFO.
ENDIF.
EXIT.
ENDIF.
LN_SIZE = LN_SIZE + LN.
APPEND WA_INFO TO INFO.
ENDDO.
CLOSE DATASET DSN.
ENDIF.
CONCATENATE 'C:\ERP_DRGS\'TEMP1 INTO TEMP2.
path = TEMP2.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = LN_SIZE
FILENAME = PATH
FILETYPE = 'BIN'
TABLES
DATA_TAB = INFO
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC EQ 0.
MESSAGE 'SUCESSFULLY TRASFERED ' TYPE 'I'.
endif.
ELSE.
MESSAGE 'FILE NOT EXISTING ' TYPE 'E'.
ENDIF.
ENDFORM. " DOWNLOAD_DRAWING
*&---------------------------------------------------------------------*
*& Module LONG_TEXT OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE LONG_TEXT OUTPUT.
READ TABLE it_ul_dtl INTO wa_ul_dtl INDEX 1.
DATA: BEGIN OF LTEXT OCCURS 100.
INCLUDE STRUCTURE TLINE.
DATA : END OF LTEXT.
REFRESH :LTEXT , lt_texttab .
TYPES: BEGIN OF TY_POTEXT,
POTEXT LIKE ZMM_PLHISTN-DESCRIPTION,
" PL_NO LIKE ZMM_PLHISTN-PL_NO,
" SL_NO LIKE ZMM_PLHISTN-SL_NO,
END OF TY_POTEXT.
DATA : IT_POTEXT TYPE TABLE OF TY_POTEXT WITH HEADER LINE,
WA_POTEXT LIKE LINE OF IT_POTEXT.
if wa_ul_dtl IS NOT INITIAL .
MOVE wa_ul_dtl-MATNR TO LV_TDNAME.
*if clt_texttab[] is INITIAL .
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = 'BEST'
LANGUAGE = 'E'
NAME = LV_TDNAME
OBJECT = 'MATERIAL'
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
IF SY-SUBRC EQ 0.
CLEAR pr_string.
LOOP AT LTEXT .
WA_POTEXT-POTEXT = LTEXT-TDLINE.
APPEND WA_POTEXT TO lt_texttab .
CONCATENATE pr_string WA_POTEXT INTO PR_STRING .
ENDLOOP.
ENDIF.
ENDIF.
*ELSE.
* APPEND LINES OF clt_texttab to lt_texttab.
*ENDIF .
ENDMODULE. " LONG_TEXT OUTPUT
*&---------------------------------------------------------------------*
*& Module SPL_CONDITION OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE SPL_CONDITION OUTPUT.
CLEAR : LV_TDNAME,WA_POTEXT.
CLEAR SPL_STRING.
REFRESH : LTEXT ,lt_texttab1 .
READ TABLE it_ul_dtl INTO wa_ul_dtl INDEX 1.
IF WA_UL_DTL IS NOT INITIAL .
CONCATENATE WA_ul_dtl-MATNR 'ICFRIC' INTO LV_TDNAME.
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = '0001'
LANGUAGE = 'E'
NAME = LV_TDNAME
OBJECT = 'MVKE'
TABLES
LINES = LTEXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
IF SY-SUBRC EQ 0.
LOOP AT LTEXT .
WA_POTEXT-POTEXT = LTEXT-TDLINE.
CONCATENATE SPL_STRING WA_POTEXT INTO SPL_STRING .
APPEND WA_POTEXT TO lt_texttab1 .
ENDLOOP.
ENDIF.
ENDIF.
ENDMODULE. " SPL_CONDITION OUTPUT
*&---------------------------------------------------------------------*
*& Form LONG_TEXT_SAVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LONG_TEXT_SAVE .
FIELD-SYMBOLS <text_string> TYPE ANY .
DATA: text_string TYPE soli_tab,
modify type i value 1.
REFRESH Tlt_texttab.
CLEAR : LG_TEXT ,SPL_TEXT, TEXT_STRING.
APPEND LINES OF clt_texttab TO Tlt_texttab.
CALL METHOD TEXT_EDITOR->GET_TEXT_AS_R3TABLE
EXPORTING
ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE
IMPORTING
TABLE = clt_texttab
IS_MODIFIED = modify
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
ERROR_DP_CREATE = 3
POTENTIAL_DATA_LOSS = 4
others = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
if modify eq 0 .
APPEND LINES OF Tlt_texttab TO clt_texttab.
endif.
ENDIF.
*
*
* CALL METHOD CL_GUI_CFW=>FLUSH
* EXCEPTIONS
* CNTL_SYSTEM_ERROR = 1
* CNTL_ERROR = 2
* OTHERS = 3.
ENDFORM. " LONG_TEXT_SAVE
*&---------------------------------------------------------------------*
*& Form SPL_CONDITION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SPL_CONDITION .
DATA: text_string1 TYPE soli_tab,
modify type i value 1.
REFRESH Tlt_texttab1 .
APPEND LINES OF Clt_texttab1 TO Tlt_texttab1 .
CALL METHOD TEXT_EDITOR1->GET_TEXT_AS_R3TABLE
EXPORTING
ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE
IMPORTING
TABLE = clt_texttab1
IS_MODIFIED = modify
EXCEPTIONS
ERROR_DP = 1
ERROR_CNTL_CALL_METHOD = 2
ERROR_DP_CREATE = 3
POTENTIAL_DATA_LOSS = 4
others = 5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
if modify eq 0 .
APPEND LINES OF Tlt_texttab1 TO Clt_texttab1 .
endif.
ENDIF.
ENDFORM. " SPL_CONDITION
*&---------------------------------------------------------------------*
*& Form LONG_SAVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LONG_SAVE .
DATA WA_LT LIKE LINE OF LT_TEXTTAB.
IF Clt_texttab IS NOT INITIAL.
flag = 1.
REFRESH lt_texttab.
APPEND LINES OF Clt_texttab TO lt_texttab.
PERFORM LOG_FILE.
PERFORM update_long_text.
ENDIF.
READ TABLE lt_texttab INTO WA_LT INDEX 1.
ENDFORM. " LONG_SAVE
*&---------------------------------------------------------------------*
*& Form SPL_SAVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SPL_SAVE .
IF Clt_texttab1 IS NOT INITIAL.
REFRESH lt_texttab1.
flag = 1.
APPEND LINES OF Clt_texttab1 TO lt_texttab1.
PERFORM log_file_spl_condition .
PERFORM SAVE_SPL_SCONDITION .
ENDIF.
READ TABLE lt_texttab1 INTO WA_LT INDEX 1.
ENDFORM. " SPL_SAVE
*&---------------------------------------------------------------------*
*& Form LOG_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LOG_FILE .
DATA : IT_PLHIST TYPE STANDARD TABLE OF ZMM_PLHISTN ,
WA_PLHIST LIKE LINE OF IT_PLHIST.
DATA : PR_KEY LIKE ZMM_PLHISTN-TEMP_SLNO,
VER_NO LIKE ZMM_PLHISTN-VER_NO,
sr_num TYPE i.
data : pl_num TYPE char8.
pl_num = plno.
SELECT SINGLE MAX( TEMP_SLNO ) FROM ZMM_PLHISTN INTO PR_KEY.
SELECT SINGLE MAX( VER_NO ) FROM ZMM_PLHISTN INTO VER_NO WHERE PL_NO = PL_num.
ver_no = ver_no + 1.
sr_num = pr_key.
LOOP AT LT_TEXTTAB INTO WA_LT.
sr_num = sr_num + 1.
WA_PLHIST-TEMP_SLNO = sr_num.
WA_PLHIST-PL_NO = PL_num.
WA_PLHIST-DATE_CREATED = SY-DATUM.
WA_PLHIST-TIME_CREATED = SY-UZEIT.
WA_PLHIST-USER_CREATED = SY-UNAME.
WA_PLHIST-VER_NO = VER_NO.
WA_PLHIST-DESCRIPTION = wa_lt-line.
APPEND WA_PLHIST to IT_PLHIST .
CLEAR : WA_PLHIST,wa_lt.
ENDLOOP.
MODIFY ZMM_PLHISTN FROM TABLE IT_PLHIST.
COMMIT WORK.
ENDFORM. " LOG_FILE
*&---------------------------------------------------------------------*
*& Form LOG_FILE_SPL_CONDITION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LOG_FILE_SPL_CONDITION .
CLEAR wa_lt.
DATA : IT_PLHIST TYPE STANDARD TABLE OF ZMM_PLHISTN ,
WA_PLHIST LIKE LINE OF IT_PLHIST.
DATA : PR_KEY LIKE ZMM_PLHISTN-TEMP_SLNO,
VER_NO LIKE ZMM_PLHISTN-VER_NO,
sr_num TYPE i.
data : pl_num TYPE char8.
pl_num = plno.
SELECT SINGLE MAX( TEMP_SLNO ) FROM ZMM_PLHISTN INTO PR_KEY.
SELECT SINGLE MAX( VER_NO ) FROM ZMM_PLHISTN INTO VER_NO WHERE PL_NO = PL_num.
ver_no = ver_no + 1.
sr_num = pr_key.
LOOP AT LT_TEXTTAB1 INTO WA_LT.
sr_num = sr_num + 1.
WA_PLHIST-TEMP_SLNO = sr_num.
WA_PLHIST-PL_NO = PL_num.
WA_PLHIST-DATE_CREATED = SY-DATUM.
WA_PLHIST-TIME_CREATED = SY-UZEIT.
WA_PLHIST-USER_CREATED = SY-UNAME.
WA_PLHIST-VER_NO = VER_NO.
WA_PLHIST-SPL_CONDITION = wa_lt-line.
APPEND WA_PLHIST to IT_PLHIST .
CLEAR : WA_PLHIST,wa_lt.
ENDLOOP.
MODIFY ZMM_PLHISTN FROM TABLE IT_PLHIST.
COMMIT WORK.
ENDFORM. " LOG_FILE_SPL_CONDITION
*&---------------------------------------------------------------------*
*& Form UPDATE_LONG_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPDATE_LONG_TEXT .
DATA: T_FLINES TYPE STANDARD TABLE OF TLINE WITH HEADER LINE,
WA_TLINE TYPE TLINE.
CLEAR LV_TDNAME.
REFRESH T_FLINES.
LOOP AT LT_TEXTTAB INTO WA_LT.
WA_TLINE-TDLINE = SY-TABIX.
T_FLINES-TDLINE = wa_lt-line.
APPEND T_FLINES.
CLEAR T_FLINES-TDLINE.
ENDLOOP.
LOOP AT IT_UL_DTL INTO WA_UL_DTL.
MOVE WA_UL_DTL-MATNR TO LV_TDNAME.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
FID = 'BEST'
FLANGUAGE = SY-LANGU
FNAME = LV_TDNAME
FOBJECT = 'MATERIAL'
SAVE_DIRECT = 'X'
FFORMAT = ' '
TABLES
FLINES = T_FLINES.
ENDLOOP.
ENDFORM. " UPDATE_LONG_TEXT
*&---------------------------------------------------------------------*
*& Form SAVE_SPL_SCONDITION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SAVE_SPL_SCONDITION .
DATA: T_FLINES TYPE STANDARD TABLE OF TLINE WITH HEADER LINE,
WA_TLINE TYPE TLINE.
CLEAR LV_TDNAME.
REFRESH T_FLINES.
LOOP AT LT_TEXTTAB1 INTO WA_LT.
WA_TLINE-TDLINE = SY-TABIX.
T_FLINES-TDLINE = wa_lt-line.
APPEND T_FLINES.
CLEAR T_FLINES-TDLINE.
ENDLOOP.
LOOP AT IT_UL_DTL INTO WA_UL_DTL.
CONCATENATE WA_UL_DTL-MATNR 'ICFRIC' INTO LV_TDNAME.
CALL FUNCTION 'CREATE_TEXT'
EXPORTING
FID = '0001'
FLANGUAGE = SY-LANGU
FNAME = LV_TDNAME
FOBJECT = 'MVKE'
SAVE_DIRECT = 'X'
FFORMAT = ' '
TABLES
FLINES = T_FLINES.
ENDLOOP.
ENDFORM. " SAVE_SPL_SCONDITION
Nice tutorial easy to understand .You solved my problem Thanks
ReplyDelete