Wednesday, March 16, 2022

Drop Down lists in the selection parameters

PROGRAM ztest.

 TYPE-POOLS: vrm.

 DATA: name TYPE vrm_id,

       list TYPE vrm_values,

       value LIKE LINE OF list.

 

PARAMETERS: ps_parm(10) AS LISTBOX VISIBLE LENGTH 10.

AT SELECTION-SCREEN OUTPUT.

  name = 'PS_PARM'.

  value-key = '1'.

  value-text = 'Line 1'.

  APPEND value TO list.

  value-key = '2'.

  value-text = 'Line 2'.

  APPEND value TO list.

  CALL FUNCTION 'VRM_SET_VALUES'

    EXPORTING id     = name

              values = list.

             

START-OF-SELECTION.

  WRITE: / 'Parameter:', ps_parm.

report test1.

type-pools: vrm.

data: it_val type vrm_values,

      w_line like line of it_val.

parameters p_bukrs like t001-bukrs as listbox

           visible length 25 obligatory.

 

initialization.

  select bukrs butxt from t001 into (w_line-key, w_line-text).

    append w_line to it_val.

    check p_bukrs is initial.

    p_bukrs = w_line-key.

  endselect.

 

at selection-screen output.

  call function 'VRM_SET_VALUES'

       exporting

            id     = 'P_BUKRS'

            values = it_val.

 

end-of-selection.

  write: / 'Company Code:', p_bukrs.

 


Thursday, January 20, 2022

Upload a picture into SAP and save it as standard text

REPORT ZPICUPLOAD LINE-SIZE 250.

*
INCLUDE OLE2INCL"OLE INCLUDE
************************************************************************
*
PARAMETERS:
   PICFILE(128TYPE DEFAULT 'C:\temp\xyz.jpg'"PCFILE TO UPLOAD
   TEXTNAME(128TYPE DEFAULT 'GOMERA'.         "NAME OF STANDARD TEXT
*
************************************************************************
DATATEXTTAB LIKE TLINE OCCURS 2000 WITH HEADER LINE.
DATABEGIN OF HEXTAB OCCURS 1000,
      LINE(33TYPE X,
      END OF HEXTAB.
DATASIZE TYPE .                    "SIZE OF FILE'
DATATEXTHEAD LIKE THEAD.
DATANAVIAGTOR TYPE OLE2_OBJECT.
************************************************************************
START-OF-SELECTION.
*
  PERFORM UPLOAD_PIC USING PICFILE TEXTNAME.
  PERFORM DOWNLOAD_PIC USING 'D:\TEMP\SAPTEST.JPG' TEXTNAME.
  PERFORM SHOW_PIC USING 'D:\TEMP\SAPTEST.JPG'.
*
END-OF-SELECTION.
*
************************************************************************
*                  upload picture (.jpg)
************************************************************************
FORM UPLOAD_PIC USING OSFILE SAPFILE.
 TEXTHEAD-TDNAME SAPFILE.
  CALL FUNCTION 'WS_UPLOAD'
       EXPORTING
            CODEPAGE '8400'
            FILETYPE 'BIN'
            FILENAME OSFILE
       IMPORTING
            FILELENGTH SIZE
       TABLES
            DATA_TAB HEXTAB
       EXCEPTIONS
            OTHERS   7.
  CALL FUNCTION 'INIT_TEXT'
       EXPORTING
            ID       'ST'
            LANGUAGE 'E'
            NAME     TEXTHEAD-TDNAME
            OBJECT   'TEXT'
       IMPORTING
            HEADER   TEXTHEAD
       TABLES
            LINES    TEXTTAB
       EXCEPTIONS
            OTHERS   5.
  CALL FUNCTION 'SAVE_TEXT'
       EXPORTING
            CLIENT          SY-MANDT
            HEADER          TEXTHEAD
            SAVEMODE_DIRECT 'X'
       TABLES
            LINES           TEXTTAB
       EXCEPTIONS
            OTHERS          5.
ENDFORM.                               "END OF UPLOADING
************************************************************************
*       FORM DOWNLOAD_PIC                                             *
************************************************************************
FORM DOWNLOAD_PIC USING OSFILE SAPFILE.
  LOOP AT TEXTTAB.
    HEXTAB-LINE TEXTTAB-TDLINE.
    APPEND HEXTAB.
  ENDLOOP.
  CALL FUNCTION 'WS_DOWNLOAD'
       EXPORTING
            BIN_FILESIZE SIZE
            CODEPAGE     '8400'
            FILENAME     OSFILE
            FILETYPE     'BIN'
       TABLES
            DATA_TAB     HEXTAB
       EXCEPTIONS
            OTHERS       7.
ENDFORM.                               " ENDOF DOWNLOAD PICTURE
************************************************************************
*       FORM SHOW_PIC                                                 *
************************************************************************
FORM SHOW_PIC USING OSFILE.
  DATA PATH(128TYPE C.
  CREATE OBJECT NAVIAGTOR 'INTERNETEXPLORER.APPLICATION'.
  SET PROPERTY OF NAVIAGTOR 'MENUBAR' 0.
  SET PROPERTY OF NAVIAGTOR 'TOOLBAR' 0.
  SET PROPERTY OF NAVIAGTOR 'STATUSBAR' 1.
  CONCATENATE 'FILE://' OSFILE INTO PATH.
  CALL METHOD OF NAVIAGTOR 'NAVIGATE' EXPORTING #1 PATH.
  SET PROPERTY OF NAVIAGTOR 'STATUSTEXT' 'PICTURE FROM SAP'.
  SET PROPERTY  OF NAVIAGTOR 'VISIBLE' 1.
ENDFORM.                               " ENDOF SHOW_PIC.