SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Change Purchase Order using ME22 Batch Input



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Sep 29, 2007 3:58 pm    Post subject: Change Purchase Order using ME22 Batch Input Reply with quote

Code:
REPORZ z_po_change.
data : i_error like bdcmsgcoll occurs 0 with header line.
data : i_bdcdata like bdcdata occurs 0 with header line.
tables : ekko, ekpo.
data :c1(10) value 'ME22',
c2(1) value ',',c3(10).
data : var1(20). " LIKE EKKO-EBELN.
data : var2 like ekko-ebeln.
data : begin of i_ekko occurs 0,
header(2),
ebeln like ekko-ebeln,
end of i_ekko.
data : begin of i_ekpo occurs 0,
item(2),
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
menge(10), " LIKE EKPO-MENGE,
end of i_ekpo.
data : v like ekpo-ebelp.
data: begin of itab occurs 0,
text(300),
end of itab.
parameters: p_file like ibipparms-path.
*PARAMETERS: PONUMBER LIKE EKPO-EBELN.
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
* FIELD_NAME = ' '
importing
file_name = p_file
.
start-of-selection.
*SELECT EBELN FROM EKKO INTO TABLE I_EKKO WHERE EBELN = PONUMBER.
*
* SELECT EBELN EBELP MENGE FROM EKPO INTO TABLE I_EKPO WHERE EBELN
*= PONUMBER.
*
perform get_data.
*LOOP AT ITAB.
* WRITE :/ ITAB.
* ENDLOOP.
loop at itab.
var1 = itab-text+0(1).
if var1 = 'H'.
*I_EKKO-EBELN = ITAB-TEXT.
split itab at c2 into i_ekko-header
i_ekko-ebeln.
* SPLIT ITAB AT ',' INTO I_EKKO-EBELN.
** " I_EKPO-EBELP
** " I_EKPO-MENGE
** " var1.
append i_ekko.
else.
split itab at c2 into i_ekpo-item
i_ekpo-ebeln
i_ekpo-ebelp
i_ekpo-menge.
append i_ekpo.
endif.
*var2 = i_ekpo-ebeln.
* MOVE VAR1 TO I_EKPO-EBELN.
* MOVE VAR1 TO I_EKKO-EBELN.
* APPEND: I_EKPO.
*if not var1 is initial.
* split var1 at ',' into i_ekpo-ebelp
* i_ekpo-menge.
* i_ekpo-ebeln = var2.
* append i_ekpo.
*endif.
endloop.
loop at i_ekpo.
write :/ i_ekpo.
endloop.
*
loop at i_ekko.
perform fill_data. " TABLES I_EKPO.
endloop.
* LOOP AT I_EKPO.
* WRITE :/ I_EKPO.
* ENDLOOP.
*&---------------------------------------------------------------------
*& Form GET_DATA
*&---------------------------------------------------------------------
* text
*----------------------------------------------------------------------
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------
*LOOP AT I_ERROR.
* WRITE :/ I_ERROR.
* ENDLOOP.
*
form get_data.
call function 'WS_UPLOAD'
exporting
codepage = ' '
filename = p_file
filetype = 'ASC'
headlen = ' '
line_exit = ' '
trunclen = ' '
user_form = ' '
user_prog = ' '
dat_d_format = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = itab
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " GET_DATA
*&---------------------------------------------------------------------
*& Form FILL_DATA
*&---------------------------------------------------------------------
* text
*----------------------------------------------------------------------
* -->P_I_EKPO text
*----------------------------------------------------------------------
form fill_data. " tables i_ekpo .
perform bdcscreen using 'SAPMM06E' '0105'.
perform bdcfield using 'RM06E-BSTNR' i_ekko-ebeln.
perform bdcfield using 'BDC_OKCODE' '/00'.
loop at i_ekpo where ebeln = i_ekko-ebeln.
* V = I_EKPO-EBELP.
perform bdcscreen using 'SAPMM06E' 0120.
perform bdcfield using 'BDC_CURSOR' 'RM06E-EBELP'.
perform bdcfield using 'RM06E-EBELP' i_ekpo-ebelp.
perform bdcfield using 'BDC_OKCODE' '/00'.
perform bdcscreen using 'SAPMM06E' 0120.
perform bdcfield using 'BDC_CURSOR' 'EKPO-MENGE(01)'.
perform bdcfield using 'RM06E-EBELP' i_ekpo-ebelp.
perform bdcfield using 'EKPO-MENGE(01)' i_ekpo-menge.
perform bdcfield using 'BDC_OKCODE' '/00'.
*PERFORM BDCSCREEN USING 'SAPMM06E' 0120.
*
*PERFORM BDCFIELD USING 'BDC_CURSOR' 'RMO6E-EBELP'.
*
*CLEAR V.
endloop.
perform bdcfield using 'BDC_OKCODE' '=BU'.
call transaction c1 using i_bdcdata mode 'A'
messages into i_error.
refresh i_bdcdata.
endform. " FILL_DATA
*&---------------------------------------------------------------------
*& Form BDCSCREEN
*&---------------------------------------------------------------------
* text
*----------------------------------------------------------------------
* -->P_0140 text
* -->P_0120 text
*----------------------------------------------------------------------
form bdcscreen using p_program p_screen.
i_bdcdata-program = p_program.
i_bdcdata-dynpro = p_screen.
i_bdcdata-dynbegin = 'X'.
append i_bdcdata.
clear i_bdcdata.
endform. " BDCSCREEN
*&---------------------------------------------------------------------
*& Form BDCFIELD
*&---------------------------------------------------------------------
* text
*----------------------------------------------------------------------
* -->P_0145 text
* -->P_I_EKPO_EBELN text
*----------------------------------------------------------------------
form bdcfield using fnam fval.
i_bdcdata-fnam = fnam.
i_bdcdata-fval = fval.
append i_bdcdata.
clear i_bdcdata.
endform. " BDCFIELD
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.