SMARTFORM Translator mit RFC Excel

Hinweise, Tips und Tricks, FAQs - keine Anfragen!!

SMARTFORM Translator mit RFC Excel

Postby Tron » Fri Feb 01, 2019 8:48 am

Moin.
Bin gerade dabei ältere RFC VBA Programme auf GUI750 umzustellen.
Da fiel mir mein alter SMARTFORMS Übersetzer in die Hände.
Interessant ist dabei , das durch die Unicode unterstützung auch Übersetzungen mit chinesischen und kyrillischen Schriften kein Problem mehr darstellen.
(Habs mal mit Google - Translate durchgeführt... geht direkt mit Paste & Copy)
Ich hatte das Tool mal entwickelt, um Excel sheets in die Fachbereiche zu geben, da vermutlich niemand alle Sprachen beherrscht und ich nicht die Verantwortung
für Übersetzungen von Fachbegriffen übernehmen möchte.

005.png
005.png (223.93 KiB) Viewed 274 times


Hier der RFC-fähige Funktionsbaustein:
Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. FUNCTION Z_BC_SF_TRANSLATION.
  2. *"----------------------------------------------------------------------
  3. *"*"Local Interface:
  4. *"  IMPORTING
  5. *"     VALUE(SOURCELANG) TYPE  SPRAS
  6. *"     VALUE(TARGETLANG) TYPE  SPRAS
  7. *"     VALUE(FORMNAME) TYPE  TDOBNAME
  8. *"     VALUE(ACTION) TYPE  CHAR01 DEFAULT 'S'
  9. *"     VALUE(DOCSTATE) TYPE  CHAR01 DEFAULT 'A'
  10. *"     VALUE(FILLMODE) TYPE  CHAR01 DEFAULT '1'
  11. *"  EXPORTING
  12. *"     VALUE(OLWRKOBJ) TYPE  LWRKOBJ
  13. *"  TABLES
  14. *"      TARGETTEXT STRUCTURE  STXFTXT
  15. *"  EXCEPTIONS
  16. *"      ERROR_IN_UPDATE
  17. *"      INPUT_PARA_ERROR
  18. *"      FORM_NOT_FOUND
  19. *"      NO_TEXT_FOUND
  20. *"      CANT_UPDATE_MASTERLANG
  21. *"----------------------------------------------------------------------
  22.   DATA ls_stxfadm TYPE stxfadm.
  23.   DATA ls_lwrkobj TYPE lwrkobj.
  24.   DATA lt_lwrkobj TYPE TABLE OF lwrkobj.
  25.   DATA ls_tartxt TYPE stxftxt.
  26.   DATA ls_srctxt TYPE stxftxt.
  27.   DATA lt_uptxt TYPE TABLE OF tline.
  28.   DATA ls_uptxt TYPE tline.
  29.   DATA lt_stext TYPE TABLE OF stxftxt.
  30.   FIELD-SYMBOLS <p> TYPE stxftxt.
  31.  
  32.   IF sourcelang IS INITIAL OR
  33.      targetlang IS INITIAL OR
  34.        formname IS INITIAL.
  35.     RAISE input_para_error.
  36.   ENDIF.
  37.  
  38.   IF action NA 'SRU'.
  39.     RAISE input_para_error.
  40.   ENDIF.
  41.  
  42.  SELECT SINGLE * FROM stxfadm INTO ls_stxfadm WHERE formname = formname.
  43.  
  44.   IF sy-subrc NE 0.
  45.     RAISE form_not_found.
  46.   ENDIF.
  47.  
  48.  
  49.   ls_lwrkobj-targetlang = targetlang.
  50.   ls_lwrkobj-objtype = 'SSF'.
  51.   ls_lwrkobj-objname = ls_stxfadm-formname.
  52.   ls_lwrkobj-devclass = ls_stxfadm-devclass.
  53.   ls_lwrkobj-masterlang = ls_stxfadm-masterlang.
  54.   ls_lwrkobj-sourcelang = sourcelang.
  55.   ls_lwrkobj-uname = ls_stxfadm-lastuser.
  56.   ls_lwrkobj-udate = ls_stxfadm-lastdate.
  57.   ls_lwrkobj-utime = ls_stxfadm-lasttime.
  58.  
  59.  
  60.   APPEND ls_lwrkobj TO lt_lwrkobj.
  61.  
  62.   CALL FUNCTION 'SSFTR_GET_STATUS'
  63.     EXPORTING
  64.       sourcelang = sourcelang
  65.       targetlang = targetlang
  66.     TABLES
  67.       OBJECTS    = lt_lwrkobj.
  68.  
  69.   LOOP AT lt_lwrkobj INTO olwrkobj.
  70.     EXIT.
  71.  
  72.   IF action = 'S'.
  73.     EXIT.
  74.   ENDIF.
  75.  
  76.   IF action = 'U'.
  77.  
  78.     SELECT * FROM stxftxt INTO TABLE lt_stext WHERE
  79.     spras = ls_stxfadm-masterlang AND
  80.     txtype = 'F' AND
  81.     formname = ls_stxfadm-formname.
  82.  
  83.     IF sy-subrc NE 0.
  84.       RAISE no_text_found.
  85.     ENDIF.
  86.  
  87. * Zeile ergänzen
  88.     LOOP AT targettext ASSIGNING <p>.
  89.       <p>-spras = ls_lwrkobj-targetlang.
  90.       <p>-txtype = 'F'.
  91.       <p>-formname = ls_lwrkobj-objname.
  92.  
  93. * Prüfen
  94.       READ TABLE lt_stext
  95.       WITH KEY txtype = 'F' formname = <p>-formname
  96.                iname  = <p>-iname linenr = <p>-linenr
  97.       INTO ls_tartxt.
  98. * Übernehme Zeilenformat von Originalsprache
  99.       IF sy-subrc = 0.
  100.         <p>-tdformat = ls_tartxt-tdformat.
  101.       ELSE.
  102. * Markiere Löschung wenn nicht in Orig.sprache
  103.         CLEAR <p>-spras.
  104.       ENDIF.
  105.     ENDLOOP.
  106.  
  107. * Lösche was nicht passt
  108.     DELETE targettext WHERE spras IS INITIAL.
  109.     SORT targettext ASCENDING BY iname linenr.
  110.  
  111.  
  112. *  ggf. mit LEER-Zeilen auffüllen
  113.     IF fillmode = '1'.
  114.  
  115.       LOOP AT targettext INTO ls_tartxt.
  116.         AT NEW iname.
  117.           LOOP AT lt_stext ASSIGNING <p>
  118.           WHERE iname = ls_tartxt-iname.
  119.             READ TABLE targettext
  120.             WITH KEY iname  = <p>-iname
  121.                      linenr = <p>-linenr
  122.             TRANSPORTING NO FIELDS.
  123.             IF sy-subrc NE 0.
  124.               <p>-spras = space.
  125.             ENDIF.
  126.           ENDLOOP.
  127.         ENDAT.
  128.       ENDLOOP.
  129.  
  130.     ENDIF.
  131.  
  132.     UNASSIGN <p>.
  133.  
  134.     LOOP AT lt_stext INTO ls_tartxt WHERE spras = space.
  135.       CLEAR ls_tartxt-tdline.
  136.       ls_tartxt-spras = ls_lwrkobj-targetlang.
  137.       APPEND ls_tartxt TO targettext.
  138.     ENDLOOP.
  139.     SORT targettext ASCENDING BY iname linenr.
  140.  
  141.  
  142.     LOOP AT targettext INTO ls_tartxt.
  143.       AT NEW iname.
  144.         ls_uptxt-tdformat = '/E'.
  145.         CONCATENATE '&' ls_tartxt-iname '&' INTO ls_uptxt-tdline.
  146.         APPEND ls_uptxt TO lt_uptxt.
  147.       ENDAT.
  148.       ls_uptxt-tdformat = ls_tartxt-tdformat.
  149.       ls_uptxt-tdline = ls_tartxt-tdline.
  150.       APPEND ls_uptxt TO lt_uptxt.
  151.     ENDLOOP.
  152.  
  153.     CALL FUNCTION 'SSFTR_SET_TEXT'
  154.       EXPORTING
  155.         targetlang      = ls_lwrkobj-targetlang
  156.         sourcelang      = ls_lwrkobj-sourcelang
  157.         docstate        = docstate
  158.       TABLES
  159.         targettext      = lt_uptxt
  160.       CHANGING
  161.         tlwrkobj        = olwrkobj
  162.       EXCEPTIONS
  163.         error_in_update = 1
  164.         OTHERS          = 2.
  165.  
  166.     IF sy-subrc <> 0.
  167.       RAISE error_in_update.
  168.     ENDIF.
  169.  
  170.   ELSE. " action = R
  171.  
  172.     SELECT * FROM stxftxt INTO TABLE targettext WHERE
  173.     spras = sourcelang AND
  174.     txtype = 'F' AND
  175.     formname = ls_stxfadm-formname.
  176.     IF sy-subrc = 0.
  177.       SORT targettext ASCENDING BY iname linenr.
  178.     ENDIF.
  179.   ENDIF.
  180.  
  181.  
GeSHi ©


Beispiel :
001.png
001.png (241.83 KiB) Viewed 274 times


gruß Jens
Bin mal gespannt, ob das Tool gut ankommt. 8-)
Tron
.....
.....
 
Posts: 1081
Joined: Sat Aug 04, 2007 10:21 pm

Return to Tips + Tricks & FAQs

Who is online

Users browsing this forum: No registered users and 2 guests

cron
  • Latest Topics