Code für LSMW

*ZPM_EQUIPL-POS = QUELLEPOS-VORNR.
DATA: lv_pos(4), lv_count type i.
lv_pos = QUELLEPOS-VORNR.
replace ‘0’ with ” into lv_pos+3(1).
lv_count = 1.
while lv_count < 3.
replace ‘0’ with ” into lv_pos(lv_count).
add 1 to lv_count.
endwhile.
CONDENSE lv_pos.
ZPM_EQUIPL-POS = lv_pos.
*************************************
* Diese LSMW soll nur benutzt werden um Daten umzusetzen
* Also keinen Batch erzeugen und laufen lassen!
* Nur zum Einlesen der Lang- Texte gedacht
ZPM_EQUIPL-TXLINE2 = QUELLEPOS-LTXT1(72).
FIELD-SYMBOLS: <f1> TYPE ANY, <form> TYPE ANY, <form2> TYPE ANY.
Data: ls_header type THEAD.
data: lt_lines  type standard table of tline, ls_lines  type tline,
lv_key1(8), lv_key2(8), lv_key3(8), lv_key4(8), lv_key type i,
lt_lines2  type standard table of tline,
ls_lines2  type tline.
Data: lv_len type i, lv_zaehl type i. “, lv_count type i.
Data: lv_field(50), lv_end type i, ls_eapl like eapl, lv_form(50).
Data: ls_plpo like plpo, lt_plpo type table of plpo.
Data: ls_plko like plko, lt_plko type table of plko.
Data: ls_ltxt like QUELLEPOS, lt_ltxt like table of ls_ltxt.
Data: lv_equnr like quellepos-equnr, lv_plnal like quellepos-plnal.
Data: lv_flag.
if 1 = 1.
*break-point.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING INPUT = QUELLEPOS-EQUNR
IMPORTING OUTPUT = lv_equnr.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING INPUT = QUELLEPOS-PLNAL
IMPORTING OUTPUT = lv_plnal.
select single * from eapl where EQUNR = @lv_equnr
AND PLNTY = ‘E’ AND LOEKZ NE ‘X’
AND PLNAL = @lv_plnal
INTO @ls_eapl.
If sy-subrc ne 0.
exit.
endif.
select single * from plko into ls_plko where plnnr = ls_eapl-plnnr and
plnnr = ls_eapl-plnnr and
PLNAL = ls_eapl-plnal.
lv_zaehl = 1.
refresh lt_ltxt. clear ls_ltxt.
loop at QUELLEPOS into ls_ltxt.
append ls_ltxt to lt_ltxt.
endloop.
loop at lt_ltxt into ls_ltxt. ” where vornr = quellepos-vornr.
* Dieser select mit Join ist wichtig!
SELECT *
FROM ( plpo AS a
INNER JOIN plas AS b ON a~plnkn = b~plnkn
AND a~plnnr = @ls_plko-plnnr
AND b~plnal = @ls_plko-plnal
AND vornr = @ls_ltxt-vornr
AND a~plnty = b~plnty
AND a~plnkn = b~plnkn
AND a~plnnr = b~plnnr )
INTO CORRESPONDING FIELDS OF TABLE @lt_plpo.
read table lt_plpo into ls_plpo index 1.
“with key vornr = ls_plpo-vornr into ls_plpo.
lv_key1 = ls_EAPL-PLNNR.
lv_key2 = ls_plpo-plnkn.
lv_key3 = ls_plpo-zaehl.
clear: ls_header, ls_lines.
refresh lt_lines.
concatenate SY-MANDT ‘E’ LV_KEY1 LV_KEY2 LV_KEY3 into ls_header-tdname.
* break-point.
ls_header-tdobject = ‘ROUTING’.
* ls_header-tdname   = ‘203E000000040000000100000001’.
ls_header-tdid     = ‘PLPO’.
ls_header-tdspras  = ‘D’.
ls_header-tdstyle  = ”. “‘Z_STIL’.
 ls_header-tdtitle  = ”. “‘Equipment Plan’.
ls_header-TDMACODE1 = ‘IA02SAPLCPDI’.
* Die Gleichheitszeichen müssen um eine Spalte
* nach rechts verschoben werden
*break-point.
lv_key = 45.
while lv_key > 1.
write lv_key to LV_KEY1. CONDENSE LV_KEY1.
concatenate ‘LS_LTXT-FORM’ LV_KEY1 into lv_form.
ASSIGN (lv_form) TO <form2>.
lv_key = lv_key – 1.
write lv_key to LV_KEY1. CONDENSE LV_KEY1.
concatenate ‘LS_LTXT-FORM’ LV_KEY1 into lv_form.
ASSIGN (lv_form) TO <form>.
<form2> = <form>.
if lv_key = 1 and <form> = ‘=’.
<form> = ‘*’.
endif.
endwhile.
* break-point.
ls_lines-tdformat = ‘*’.
ls_lines-tdline   = ”.
append ls_lines to lt_lines.
lv_key = 1. lv_end = 1.
while lv_key < 46.
write lv_key to LV_KEY1. CONDENSE LV_KEY1.
concatenate ‘LS_LTXT-LTXT’ LV_KEY1 into lv_field.
concatenate ‘LS_LTXT-FORM’ LV_KEY1 into lv_form.
*  break-point.
ASSIGN (lv_field) TO <f1>.
ASSIGN (lv_form) TO <form>.
if <form> = ‘=’.
ls_lines-tdformat = ‘=’.
else.
ls_lines-tdformat = ‘*’.
endif.
  if <f1> = ”.
ls_lines-tdformat = ‘/’.
ls_lines-tdline   = ”.
append ls_lines to lt_lines.
Exit.
endif.
ls_lines-tdline = <f1>.
append ls_lines to lt_lines.
add 1 to lv_key.
endwhile.
*break-point.
CALL FUNCTION ‘SAVE_TEXT’
EXPORTING
header                = ls_header
SAVEMODE_DIRECT       = ‘X’
tables
lines                 = lt_lines
EXCEPTIONS
ID                    = 1
LANGUAGE              = 2
NAME                  = 3
OBJECT                = 4
OTHERS                = 5.
*break-point.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
* Achtung: Hier kommt jetzt die entscheidende Stelle um das Langtext-
* kennzeichen zu setzen:—–>>>>>>
ls_plpo-txtsp = ‘D’.
UPDATE PLPO FROM ls_plpo.
ENDIF.
add 1 to lv_zaehl.
endloop.
*endloop.
endif.
Schlagwörter:

Ein Gedanke zu „Code für LSMW“

Schreibe einen Kommentar