Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Condition Records

Former Member
0 Likes
985

Hi,

I am uploading condition records in j3a4 transaction. I also tried VK11. I have problem in the recording. I am using call transaction, after i post the record it takes me to the first screen with out returning to the called program. If i am coding in the program for 'BACK' button it says leave to transaction is not possible. if not it says no batch input data. Can any one help me in this.

or is there a function module or BAPI to achieve this.

Thanks in advance.

3 REPLIES 3
Read only

Former Member
0 Likes
611

Can u post ur code...probably u can give No screen mode in call transaction syntax

Read only

0 Likes
611

report ZIMG_UPL_CONDITIONS

line-size 255

message-id z00.

data: c_bslash value '\', " Backward slash

c_fslash value '/'. " Forward slash

----


  • Variable declarations *

----


data: x_data_in(230) type c, " String

v_lines type i, " Total no. of lines

v_err_cnt type i, " Error count

v_msg(250) type c. " Log msg

----


  • Internal Tables *

----


  • Internal table to upload the data

data: begin of it_data_in occurs 0 ,

matnr_old(18), " Old material number

price(16), " Selling price

gcolor(3), " Grid color

gsize(5), " Grid Size

end of it_data_in.

  • Internal table with SAP Material Numbers & no grid values

data: begin of it_cond_recs occurs 0 ,

matnr(18), " SAP material number

price(16), " Selling price

end of it_cond_recs.

  • Internal table with SAP Material Numbers with grid values

data: begin of it_cond_recsg occurs 0 ,

matnr(18), " SAP material number

price(16), " Selling price

gvalue(8), " Grid value

end of it_cond_recsg.

  • Internal table for getting the BDC data

data : begin of it_bdcdata occurs 0.

include structure bdcdata. " Table to hold BDC data

data : end of it_bdcdata.

  • Internal table for reading the messages of call transaction

DATA : BEGIN OF It_MESSAGE_TAB OCCURS 0.

INCLUDE STRUCTURE BDCMSGCOLL. "Table to hold messages

DATA : END OF It_MESSAGE_TAB.

  • Internal table for Error messages

data: begin of it_error occurs 0,

matnr(18) type n, " Material no.

msg(250), " Log message

end of it_error.

  • Internal table to upload the presentation server

data: begin of it_upload occurs 0,

string(230) type c,

end of it_upload.

*----


  • Selection Screen

*----


----


  • Build Logical System Info Block *

----


selection-screen begin of block b_dsn with frame title text-001.

parameters: p_fname type rlgrap-filename. " File name

parameters: rd_pserv radiobutton group radi default 'X', " Pres. Server

rd_aserv radiobutton group radi. " App. Server

selection-screen end of block b_dsn.

*selection-screen begin of block outputfile with frame title text-002.

*parameters: p_ofile type edi_path-pthnam default '/tmp/log.txt'.

*selection-screen end of block outputfile.

*----


  • at Selection-screen

*----


  • Check which file is selected

at selection-screen on value-request for p_fname.

  • Perform to get the current value of the selection screen

perform get_current_value.

if rd_aserv = 'X'.

message i003 with 'Can not browse unix directories'(003).

else.

  • F4 help for presentation server file name

perform get_local_file_name.

endif.

at selection-screen.

  • perform to validate file name

perform validate_filename using p_fname.

    • perform to validate output file name

  • perform validate_filename using p_ofile.

*----


  • Start of selection

*----


start-of-selection.

  • Presentation File upload

if rd_pserv = 'X'.

perform ws_upload.

endif.

    • Unix File Upload

  • if rd_aserv = 'X'.

  • perform load_unix.

  • endif.

if not it_data_in[] is initial.

  • perform to process data posting

perform process_data_posting.

endif.

*----


  • End of selection

*----


end-of-selection.

if not it_error[] is initial.

write:/'Total no. of errors:', v_err_cnt.

loop at it_error.

write:/ 'Material no :', it_error-matnr,

/ 'Log Msg :', it_error-msg(70).

endloop.

else.

write:'Success'.

endif.

&----


*& Form ws_upload

&----


  • Subroutine for Uploading file

----


form ws_upload.

call function 'WS_UPLOAD'

exporting

filename = p_fname

filetype = 'DAT'

tables

data_tab = it_data_in

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 i003 with

'Unable to Upload file from presentation server'(008).

stop.

else.

delete it_data_in index 1.

endif.

endform. " ws_upload

&----


*& Form load_unix

&----


  • Form to Load Unix File

----


form load_unix.

open dataset p_fname for input in text mode.

if sy-subrc <> 0.

message i003 with p_fname.

stop.

else.

do.

clear x_data_in.

read dataset p_fname into x_data_in.

case sy-subrc.

when 0.

split x_data_in at '~'

into it_data_in-matnr_old

it_data_in-price

it_data_in-gcolor

it_data_in-gsize.

append it_data_in.

clear it_data_in.

when 4.

exit.

when 8.

message i003 with 'Unable to Read the File'(009) p_fname.

stop.

endcase.

enddo.

close dataset p_fname.

endif.

endform. " load_unix

&----


*& Form get_current_value

&----


  • Read the screen for radio button

----


form get_current_value.

  • Local internal table for screen fields

data: begin of i_dynpfields occurs 0.

include structure dynpread.

data: end of i_dynpfields.

clear i_dynpfields.

refresh i_dynpfields.

i_dynpfields-fieldname = 'RD_ASERV'.

append i_dynpfields.

call function 'DYNP_VALUES_READ'

exporting

dyname = sy-cprog

dynumb = sy-dynnr

tables

dynpfields = i_dynpfields

exceptions

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

invalid_parameter = 7

undefind_error = 8

double_conversion = 9

others = 10.

if sy-subrc <> 0.

message i999 with 'Unbale to read the selection screen values'(015).

else.

read table i_dynpfields index 1.

if sy-subrc = 0.

move i_dynpfields-fieldvalue to rd_aserv.

endif.

endif.

endform. " get_current_value

&----


*& Form get_local_file_name

&----


  • F4 help for presentation server

----


form get_local_file_name.

  • Local variable

data: l_fname like ibipparms-path, " File name

v_repid like sy-repid.

l_fname = p_fname.

v_repid = sy-repid.

call function 'F4_FILENAME'

exporting

program_name = v_repid

dynpro_number = sy-dynnr

field_name = 'P_FNAME'

importing

file_name = l_fname

exceptions

others = 1.

if sy-subrc = 0.

p_fname = l_fname.

endif.

endform. " get_local_file_name

&----


*& Form validate_filename

&----


  • To validate file name

----


form validate_filename using p_fname type any.

if rd_aserv = 'X'.

  • Local variable for file length

data : l_len type i.

l_len = strlen( p_fname ).

if p_fname ca space.

if sy-fdpos < l_len.

message e333 with 'File name should not contain spaces'(004).

endif.

endif.

if p_fname ca c_bslash.

message e333 with 'File name should not contain \'(005).

endif.

if p_fname na c_fslash. " No directory path given

message w333 with 'File will be created in home directory'(006).

endif.

endif.

if p_fname0(1) = c_fslash and p_fname1 = space.

message e333 with 'File name should not contain only /'(007).

endif.

endform. " validate_filename

&----


*& Form process_data_posting

&----


  • To process data posting

----


FORM process_data_posting.

  • perform get SAP Material number

perform get_SAP_materials.

  • perform to build BDC Data

perform build_bdc_data.

ENDFORM. " process_data_posting

&----


*& Form get_SAP_materials

&----


  • To get SAP Material numbers for the old materials

----


FORM get_SAP_materials.

  • Local variable

data: l_gvalue(8), " Grid value

l_matnr(18). " Material no.

sort it_data_in by matnr_old.

loop at it_data_in.

at new matnr_old.

select single matnr from mara into l_matnr

where bismt = it_data_in-matnr_old.

endat.

concatenate it_data_in-gcolor

it_data_in-gsize

into l_gvalue.

if l_gvalue is initial.

it_cond_recs-matnr = l_matnr.

it_cond_recs-price = it_data_in-price.

append it_cond_recs.

clear it_cond_recs.

else.

it_cond_recsg-matnr = l_matnr.

it_cond_recsg-price = it_data_in-price.

it_cond_recsg-gvalue = l_gvalue.

append it_cond_recsg.

clear it_cond_recsg.

endif.

endloop.

sort it_cond_recs by matnr.

sort it_cond_recsg by matnr.

ENDFORM. " get_SAP_materials

&----


*& Form build_bdc_data

&----


  • To build bdc data for J3a4 (Create price & SZ Condition)

----


FORM build_bdc_data.

if not it_cond_recs[] is initial.

  • perform to build BDC Data for J3a4 with out grid values

perform build_bdc_data_no_grid.

endif.

if not it_cond_recsg[] is initial.

  • perform to build BDC Data for J3a4 with grid values

perform build_bdc_data_with_grid.

endif.

ENDFORM. " build_bdc_data

&----


*& Form populate1

&----


  • To populate screen and field information

----


FORM populate1 USING value(p_a) type any

value(p_b) type any

value(p_c) type any.

if p_a = 'X'.

it_bdcdata-program = p_b.

it_bdcdata-dynpro = p_c.

it_bdcdata-dynbegin = p_a.

else.

it_bdcdata-fnam = p_b.

it_bdcdata-fval = p_c.

endif.

append it_bdcdata.

clear it_bdcdata.

ENDFORM. " populate1

&----


*& Form build_bdc_data_with_grid

&----


  • To build bdc data for J3a4 (Create price & SZ Condition)

  • with grid values

----


FORM build_bdc_data_with_grid.

data: l_gsize(18), " Field name

l_kbetr(15), " Field name

l_cnt type n, " Counter

l_cnt_c(3). " Counter

loop at it_cond_recsg.

at new matnr.

read table it_cond_recsg index sy-tabix.

perform populate1 using : 'X' 'SAPLJ3AT' '0100',

: ' ' 'RV13A-KSCHL' 'J3AP',

: ' ' 'BDC_OKCODE' '/00'.

perform populate1 using : 'X' 'SAPLV14A' '0100',

: ' ' 'RV130-SELKZ(04)' 'X',

: ' ' 'BDC_OKCODE' '=WEIT'.

endat.

l_cnt = l_cnt + 1.

l_cnt_c = l_cnt.

if l_cnt <= 13.

concatenate 'KOMG-J_3ASIZE(' l_cnt_c ')' into l_gsize.

concatenate 'KONP-KBETR(' l_cnt_c ')' into l_kbetr.

perform populate1 using : 'X' 'SAPMV13A' '1499',

: ' ' 'KOMG-VKORG' '0010',

: ' ' 'KOMG-VTWEG' '10',

: ' ' 'KOMG-MATNR' it_cond_recsg-matnr,

: ' ' l_gsize it_cond_recsg-gvalue,

: ' ' l_kbetr it_cond_recsg-price,

: ' ' 'BDC_OKCODE' '/00'.

else.

l_cnt = 1.

perform populate1 using : ' ' 'BDC_OKCODE' '=NEWP'.

endif.

at end of matnr.

perform populate1 using : 'X' 'SAPMV13A' '1499',

: ' ' 'BDC_OKCODE' '=SICH'.

  • perform populate1 using : 'X' 'SAPLJ3AT' '0100',

  • : ' ' 'BDC_OKCODE' '/EBA0'.

  • perform to call transaction J3a4

perform call_transaction.

clear l_cnt.

endat.

endloop.

ENDFORM. " build_bdc_data_with_grid

&----


*& Form build_bdc_data_no_grid

&----


  • To build bdc data for J3a4 (Create price & SZ Condition)

  • with no grid values

----


FORM build_bdc_data_no_grid.

data: l_matnr(15), " Field name

l_kbetr(15), " Field name

l_cnt type n, " Counter

l_cnt_c(3). " Counter

perform populate1 using : 'X' 'SAPLJ3AT' '0100',

: ' ' 'RV13A-KSCHL' 'J3AP',

: ' ' 'BDC_OKCODE' '/00'.

perform populate1 using : 'X' 'SAPLV14A' '0100',

: ' ' 'RV130-SELKZ(06)' 'X',

: ' ' 'BDC_OKCODE' '=WEIT'.

loop at it_cond_recs.

l_cnt = l_cnt + 1.

l_cnt_c = l_cnt.

if l_cnt <= 14.

concatenate 'KOMG-MATNR(' l_cnt_c ')' into l_matnr.

concatenate 'KONP-KBETR(' l_cnt_c ')' into l_kbetr.

perform populate1 using : 'X' 'SAPMV13A' '1004',

: ' ' 'KOMG-VKORG' '0010',

: ' ' 'KOMG-VTWEG' '10',

: ' ' l_matnr it_cond_recs-matnr,

: ' ' l_kbetr it_cond_recs-price,

: ' ' 'BDC_OKCODE' '/00'.

else.

l_cnt = 1.

perform populate1 using : ' ' 'BDC_OKCODE' '=NEWP'.

endif.

endloop.

perform populate1 using : 'X' 'SAPMV13A' '1004',

: ' ' 'BDC_OKCODE' '=SICH'.

  • perform populate1 using : 'X' 'SAPLJ3AT' '0100',

  • : ' ' 'BDC_OKCODE' '/EBA0'.

  • To call the transaction J3a4

perform call_transaction.

ENDFORM. " build_bdc_data_no_grid

&----


*& Form call_transaction

&----


  • To call the transaction J3a4

----


FORM call_transaction.

  • Structure declaration for options

data: x_opt like ctu_params.

x_opt-DISMODE = 'N'. " No Screen Mode

x_opt-UPDMODE = 'S'. " Update mode "Synchronous or Asynchronous

x_opt-DEFSIZE = 'X'. " Sets to the default size of the window

  • call the transaction J3a4

CALL TRANSACTION 'J3A4' USING It_BDCDATA

MESSAGES INTO it_MESSAGE_TAB

options from x_opt.

if sy-subrc <> 0.

v_err_cnt = v_err_cnt + 1.

clear v_lines.

describe table it_message_tab lines v_lines.

read table it_message_tab index v_lines.

  • Perform to read the messages

perform message_format.

  • Appending the error records into error table

it_error-matnr = it_cond_recsg-matnr. " Material No.

it_error-msg = v_msg. " Error message

append it_error.

clear it_error.

endif.

REFRESH: It_BDCDATA,

it_message_tab.

CLEAR: It_BDCDATA,

it_message_tab.

ENDFORM. " call_transaction

&----


*& Form message_format

&----


  • Subroutine to read the messages

----


FORM message_format.

CLEAR V_MSG.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

ID = It_MESSAGE_TAB-MSGID

LANG = 'EN'

NO = It_MESSAGE_TAB-MSGNR

V1 = It_MESSAGE_TAB-MSGV1

V2 = It_MESSAGE_TAB-MSGV2

V3 = It_MESSAGE_TAB-MSGV3

V4 = It_MESSAGE_TAB-MSGV4

IMPORTING

MSG = V_MSG

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

V_MSG = SPACE.

ENDIF.

ENDFORM. " message_format

Check this out then. In No screen mode in the call transaction it says No batch input data.

Read only

andreas_mann3
Active Contributor
0 Likes
611

Hi Subbu,

there's an interface named <b>RV14BTCI</b> to create condition records.

-> look documentation of this report

regards Andreas