Code: Alles auswählen.
FUNCTION Z_BC_SF_TRANSLATION.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(SOURCELANG) TYPE SPRAS
*" VALUE(TARGETLANG) TYPE SPRAS
*" VALUE(FORMNAME) TYPE TDOBNAME
*" VALUE(ACTION) TYPE CHAR01 DEFAULT 'S'
*" VALUE(DOCSTATE) TYPE CHAR01 DEFAULT 'A'
*" VALUE(FILLMODE) TYPE CHAR01 DEFAULT '1'
*" EXPORTING
*" VALUE(OLWRKOBJ) TYPE LWRKOBJ
*" TABLES
*" TARGETTEXT STRUCTURE STXFTXT
*" EXCEPTIONS
*" ERROR_IN_UPDATE
*" INPUT_PARA_ERROR
*" FORM_NOT_FOUND
*" NO_TEXT_FOUND
*" CANT_UPDATE_MASTERLANG
*"----------------------------------------------------------------------
DATA ls_stxfadm TYPE stxfadm.
DATA ls_lwrkobj TYPE lwrkobj.
DATA lt_lwrkobj TYPE TABLE OF lwrkobj.
DATA ls_tartxt TYPE stxftxt.
DATA ls_srctxt TYPE stxftxt.
DATA lt_uptxt TYPE TABLE OF tline.
DATA ls_uptxt TYPE tline.
DATA lt_stext TYPE TABLE OF stxftxt.
FIELD-SYMBOLS <p> TYPE stxftxt.
IF sourcelang IS INITIAL OR
targetlang IS INITIAL OR
formname IS INITIAL.
RAISE input_para_error.
ENDIF.
IF action NA 'SRU'.
RAISE input_para_error.
ENDIF.
SELECT SINGLE * FROM stxfadm INTO ls_stxfadm WHERE formname = formname.
IF sy-subrc NE 0.
RAISE form_not_found.
ENDIF.
ls_lwrkobj-targetlang = targetlang.
ls_lwrkobj-objtype = 'SSF'.
ls_lwrkobj-objname = ls_stxfadm-formname.
ls_lwrkobj-devclass = ls_stxfadm-devclass.
ls_lwrkobj-masterlang = ls_stxfadm-masterlang.
ls_lwrkobj-sourcelang = sourcelang.
ls_lwrkobj-uname = ls_stxfadm-lastuser.
ls_lwrkobj-udate = ls_stxfadm-lastdate.
ls_lwrkobj-utime = ls_stxfadm-lasttime.
APPEND ls_lwrkobj TO lt_lwrkobj.
CALL FUNCTION 'SSFTR_GET_STATUS'
EXPORTING
sourcelang = sourcelang
targetlang = targetlang
TABLES
OBJECTS = lt_lwrkobj.
LOOP AT lt_lwrkobj INTO olwrkobj.
EXIT.
ENDLOOP.
IF action = 'S'.
EXIT.
ENDIF.
IF action = 'U'.
SELECT * FROM stxftxt INTO TABLE lt_stext WHERE
spras = ls_stxfadm-masterlang AND
txtype = 'F' AND
formname = ls_stxfadm-formname.
IF sy-subrc NE 0.
RAISE no_text_found.
ENDIF.
* Zeile ergänzen
LOOP AT targettext ASSIGNING <p>.
<p>-spras = ls_lwrkobj-targetlang.
<p>-txtype = 'F'.
<p>-formname = ls_lwrkobj-objname.
* Prüfen
READ TABLE lt_stext
WITH KEY txtype = 'F' formname = <p>-formname
iname = <p>-iname linenr = <p>-linenr
INTO ls_tartxt.
* Übernehme Zeilenformat von Originalsprache
IF sy-subrc = 0.
<p>-tdformat = ls_tartxt-tdformat.
ELSE.
* Markiere Löschung wenn nicht in Orig.sprache
CLEAR <p>-spras.
ENDIF.
ENDLOOP.
* Lösche was nicht passt
DELETE targettext WHERE spras IS INITIAL.
SORT targettext ASCENDING BY iname linenr.
* ggf. mit LEER-Zeilen auffüllen
IF fillmode = '1'.
LOOP AT targettext INTO ls_tartxt.
AT NEW iname.
LOOP AT lt_stext ASSIGNING <p>
WHERE iname = ls_tartxt-iname.
READ TABLE targettext
WITH KEY iname = <p>-iname
linenr = <p>-linenr
TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
<p>-spras = space.
ENDIF.
ENDLOOP.
ENDAT.
ENDLOOP.
ENDIF.
UNASSIGN <p>.
LOOP AT lt_stext INTO ls_tartxt WHERE spras = space.
CLEAR ls_tartxt-tdline.
ls_tartxt-spras = ls_lwrkobj-targetlang.
APPEND ls_tartxt TO targettext.
ENDLOOP.
SORT targettext ASCENDING BY iname linenr.
LOOP AT targettext INTO ls_tartxt.
AT NEW iname.
ls_uptxt-tdformat = '/E'.
CONCATENATE '&' ls_tartxt-iname '&' INTO ls_uptxt-tdline.
APPEND ls_uptxt TO lt_uptxt.
ENDAT.
ls_uptxt-tdformat = ls_tartxt-tdformat.
ls_uptxt-tdline = ls_tartxt-tdline.
APPEND ls_uptxt TO lt_uptxt.
ENDLOOP.
CALL FUNCTION 'SSFTR_SET_TEXT'
EXPORTING
targetlang = ls_lwrkobj-targetlang
sourcelang = ls_lwrkobj-sourcelang
docstate = docstate
TABLES
targettext = lt_uptxt
CHANGING
tlwrkobj = olwrkobj
EXCEPTIONS
error_in_update = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE error_in_update.
ENDIF.
ELSE. " action = R
SELECT * FROM stxftxt INTO TABLE targettext WHERE
spras = sourcelang AND
txtype = 'F' AND
formname = ls_stxfadm-formname.
IF sy-subrc = 0.
SORT targettext ASCENDING BY iname linenr.
ENDIF.
ENDIF.
ENDFUNCTION.