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

ABAP<->Java



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
agatos
Участник
Участник



Joined: 01 Nov 2007
Posts: 49
Location: Germany, Norden

PostPosted: Wed Jan 16, 2008 5:08 pm    Post subject: ABAP<->Java Reply with quote

Добрый день!
можно как-н. Java программки на ABAP платформе запустить? или вызвать из ABAP программы? Что для этого нужно?
спасибо!
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 180
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Wed Jan 16, 2008 5:29 pm    Post subject: Reply with quote

Общая идея - удаленный запуск java приложения на сервере презентаций через rfc.

1) Calling MDM JAVA-API application (executable) from ABAP

2) Making a Java Editor in ABAP and compiling it

It have two reports:
zjavacreate
zjavamodify

ZJAVACREATE:
Code:
REPORT  zjavacreate message-id zmsgnew.

*************************Creation of Internal table*******************
DATA: BEGIN OF ti_record OCCURS 200,
Line(250),
END OF ti_record.
DATA: BEGIN OF ti_rec OCCURS 200,
Line(250),
END OF ti_rec.

******************************Selection screen*************************
selection-screen begin of block b1 with frame .
Parameters create radiobutton group g1.
PARAMETERS: JavaName(30) lower case.
parameters modify radiobutton group g1.
selection-screen end of block b1.

*******************Calling the java program creation page***************
at selection-screen.
  if CREATE = 'X'.
    if javaname is not initial.
      refresh ti_record[].
   concatenate 'public class' javaname into ti_record-line separated by space.

   concatenate ti_record-line '{' into ti_record-line separated by space.
      Append ti_record.
      ti_record-line = 'public static void main(String []args){'.
      Append ti_record.
      ti_record-line ='//enter ur code here'.
      append ti_record.
      ti_record-line ='}'.
      Append ti_record.
      ti_record-line ='}'.
      Append ti_record.

      EDITOR-CALL FOR ti_record .
    else.
      Message e001.

    endif.
***************************Saving the java program*********************
data tfile type string.

concatenate 'D:\Programs\' javaname '.java' into tfile.
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME                        = tfile
    FILETYPE                        = 'ASC'
  TABLES
    DATA_TAB                        =   ti_record.
  endif.
data new(15).
  if MODIFY = 'X'.
    new = 'ZJAVAMODIFY1'.
    CALL TRANSACTION NEW.
  endif.
*****************************************************************************************


ZJAVAMODIFY:
Code:
REPORT  zjavamodify.
***********************selection screen.*********************
selection-screen begin of block b1 with frame .
Parameters compile radiobutton group g1.
Parameters modify radiobutton group g1.
Parameters execute radiobutton group g1.
PARAMETER : FILE(100) lower case.
selection-screen end of block b1.
DATA: BEGIN OF TI_RECORD OCCURS 1,
LINE(200),
END OF TI_RECORD.
data: st1(30),st2(30).

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.
  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
*     DEF_FILENAME           = ' '
      DEF_PATH               = '*.*'
*     MASK                   = ' '
*     MODE                   = ' '
*     TITLE                  = ' '
    IMPORTING
      FILENAME               = FILE
*     RC                     =
           .

End-of-selection.

********************************************************************
*****************************MODIFY*********************************
  if modify = 'X'.
    data: TXT_FILE1 TYPE STRING .
    txt_file1 = file.
**************FM GUI_UPLOAD

    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME = txt_file1
      TABLES
        DATA_TAB = ti_recORD[].
**********End FM GUI_UPLOAD
    EDITOR-CALL FOR ti_record .
**************FM GUI_UPLOAD

    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME = txt_file1
        FILETYPE = 'ASC'
      TABLES
        DATA_TAB = ti_record.
**********End FM GUI_UPLOAD
  endif.

********************end of modify********************

*******************BAT file for compilation n
execution.****************
  if compile = 'X'.
    DATA: begin of itab_bat_create occurs 0,
       row(500) type c,
      end of itab_bat_create.

    data:comp_join1(250).
    concatenate 'java' 'jCompiler' file into comp_join1
     separated
     by space.
    itab_bat_create-row = 'c:'.
    append itab_bat_create.
    itab_bat_create-row = 'cd Documents and Settings\127740'.
    append itab_bat_create.
    itab_bat_create-row = comp_join1.
    append itab_bat_create.

********FM GUI_DOWNLOAD
    data: st type string.
    st = 'C:\Documents and Settings\127740\compile_java.bat'.
    call function 'GUI_DOWNLOAD'
      EXPORTING
        filename         = st
        filetype         = 'ASC'
      TABLES
        data_tab         = itab_bat_create[]
      EXCEPTIONS
        file_open_error  = 1
        file_write_error = 2
        others           = 3.
********end FM GUI_DOWNLOAD
*****FM dvsvas_doc_ws_execute_50
    CALL FUNCTION 'DSVAS_DOC_WS_EXECUTE_50'
      EXPORTING
        PROGRAM = 'C:\Documents and Settings\127740\compile_java.bat'.
*****end FM dvsvas_doc_ws_execute_50
  endif.
************************end of compile********************************

*********************************************************************
*************************************** output***********************
  if execute = 'X'.
    data: TXT_FILE3 TYPE STRING .
    split File AT '.java' into: st1 st2  .
    concatenate st1 'error.txt' into TXT_FILE3.
**************FM GUI_UPLOAD
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME = txt_file3
      TABLES
        DATA_TAB = ti_recORD[].
**********End FM GUI_UPLOAD
    if not ti_record[] is initial.
      loop at ti_record.
        write:/ ti_record.
      endloop.
    else.
      data: TXT_FILE4 TYPE STRING .
      split File AT '.java' into: st1 st2  .
      concatenate st1 'output.txt' into TXT_FILE4.
**************FM GUI_UPLOAD
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME = TXT_FILE4
        TABLES
          DATA_TAB = ti_recORD[].
**********End FM GUI_UPLOAD
      loop at ti_record.
        write:/ ti_record.
      endloop.
    endif.
  endif.
************************end of
output****************************************


In ZJAVACREATE we have used the transaction new which is nothing but
the transaction code for zjavamodify.
Tips By : Ankit Sharma
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP 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 can 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.