cancel
Showing results for 
Search instead for 
Did you mean: 

Print a picture from an URL

Former Member
0 Kudos

HI All,

is it possible to print (using a sapscript or a report) a picture directly from an URL instead of upload this picture into SAP (with report RSTXLDMC)?

Many thanks.

Luca

Accepted Solutions (1)

Accepted Solutions (1)

former_member196280
Active Contributor
0 Kudos

It is not possible to display or print picture directly from URL in SAPScripts.

Regards,

Sairam

Answers (11)

Answers (11)

Former Member
0 Kudos

Hi

Check this report

program zsap_picture_demo.

set screen 200.

TYPE-POOLS cndp.

************************************************************************
* CLASS    c_event_receiver
* DEFINITION
************************************************************************
class c_event_receiver definition.
* The class is used to test the events raised by the cl_gui_picture
* class
  public section.
    methods event_handler_picture_dblclick
            for event picture_dblclick of cl_gui_picture
            importing mouse_pos_x mouse_pos_y sender.
    methods event_handler_context_menu
            for event context_menu of cl_gui_picture
            importing sender.
    methods event_handler_context_menu_sel
            for event context_menu_selected of cl_gui_picture
            importing fcode sender.
  endclass.


************************************************************************
* DATA
************************************************************************
  data function like sy-ucomm.         " OK-Code field in screen 200
  data url  type cndp_url.                " URL-field in screen 200
  data url2 type cndp_url.               " URL-field in screen 200
  data picture_control_1 type ref to cl_gui_picture.
  data picture_control_2 type ref to cl_gui_picture.
  data container_1 type ref to cl_gui_custom_container.
  data container_2 type ref to cl_gui_custom_container.
  data event_receiver  type ref to c_event_receiver.
  data event_tab type cntl_simple_events.
  data event_tab_line type cntl_simple_event.
  data return type i.

************************************************************************
* PBO
* before_output
************************************************************************
module before_output output.
  set pf-status 'MAIN0001'.
  IF PICTURE_CONTROL_1 IS INITIAL.

* Create controls
    create object container_1
      exporting container_name = 'PICTURE_CONTROL_1'.
    create object container_2
      exporting container_name = 'PICTURE_CONTROL_2'.

    CREATE OBJECT PICTURE_CONTROL_1 exporting parent = container_1.
    CREATE OBJECT PICTURE_CONTROL_2 exporting parent = container_2.

* Register the events
    EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_PICTURE_DBLCLICK.
    append EVENT_TAB_LINE to EVENT_TAB.
    EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_CONTEXT_MENU.
    append EVENT_TAB_LINE to EVENT_TAB.
 EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_CONTEXT_MENU_SELECTED.
    append EVENT_TAB_LINE to EVENT_TAB.

    CALL METHOD PICTURE_CONTROL_1->SET_REGISTERED_EVENTS
      exporting
        EVENTS = event_tab.

    CALL METHOD PICTURE_CONTROL_2->SET_REGISTERED_EVENTS
      exporting
        EVENTS = event_tab.

* Create the event_receiver object and set the handlers for the events
* of the picture controls
    create object event_receiver.
    set handler event_receiver->event_handler_picture_dblclick
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_context_menu
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_context_menu_sel
                FOR PICTURE_CONTROL_1.
    set handler event_receiver->event_handler_picture_dblclick
                FOR PICTURE_CONTROL_2.
    set handler event_receiver->event_handler_context_menu
                FOR PICTURE_CONTROL_2.
    set handler event_receiver->event_handler_context_menu_sel
                FOR PICTURE_CONTROL_2.

* Set the display mode to 'normal' (0)
    CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
    CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.

* Set 3D Border
    CALL METHOD PICTURE_CONTROL_1->SET_3D_BORDER
       exporting border = 1.
    CALL METHOD PICTURE_CONTROL_2->SET_3D_BORDER
       exporting border = 1.


* new async implementation since 4.6C
CALL FUNCTION 'DP_PUBLISH_WWW_URL'
  EXPORTING
    OBJID                       = 'HTMLCNTL_TESTHTM2_SAP_AG'
    LIFETIME                    = cndp_lifetime_transaction
  IMPORTING
    URL                         = url
  EXCEPTIONS
    OTHERS                      = 1.

* Load the picture by using the url generated by the data provider.
    if sy-subrc = 0.
      CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_URL_ASYNC
         exporting url = url.
    endif.

CALL FUNCTION 'DP_PUBLISH_WWW_URL'
  EXPORTING
    OBJID                       = 'DEMOWORD97SAPLOGO'
    LIFETIME                    = cndp_lifetime_transaction
  IMPORTING
    URL                         = url2
  EXCEPTIONS
    OTHERS                      = 1.

* load image
    if sy-subrc = 0.
      CALL METHOD PICTURE_CONTROL_2->LOAD_PICTURE_FROM_URL_async
         exporting url = url2.
    endif.

  endif.
endmodule.


************************************************************************
* PAI
* after_input
************************************************************************
module after_input input.
  case function.
* At the end of the program destroy the control
    when 'BACK'.
      CALL METHOD container_1->FREE.
      CALL METHOD container_2->FREE.
      leave to screen 0.

* Change the display mode
    when 'NORMAL'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
    when 'STRETCH'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
    when 'FIT'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
           EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
    when 'NORMAL_CTR'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
    EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
    EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
    when 'FIT_CTR'.
      CALL METHOD PICTURE_CONTROL_1->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
      CALL METHOD PICTURE_CONTROL_2->SET_DISPLAY_MODE
      EXPORTING DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.

* Clear the picture
    when 'CLEAR'.
      CALL METHOD PICTURE_CONTROL_1->CLEAR_PICTURE.

* Load a new picture
    when space.
      CALL METHOD PICTURE_CONTROL_1->LOAD_PICTURE_FROM_URL
           exporting url = url
           importing result = return.
      call method cl_gui_cfw=>flush.
      if return = 0.
        url = text-000.
      endif.

  endcase.

  clear function.
endmodule.


************************************************************************
* CLASS   c_event_receiver
* IMPLEMENTATION
************************************************************************
CLASS C_event_receiver implementation.

************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_picture_dblclick
************************************************************************
  METHOD EVENT_HANDLER_PICTURE_DBLCLICK.
*        for event picture_dblclick of c_picture_control
*        importing mouse_pos_x mouse_pos_y.
    DATA pos_x(5) type c.
    DATA pos_y(5) type c.
    pos_x = mouse_pos_x.
    pos_y = mouse_pos_y.

    IF SENDER = PICTURE_CONTROL_1.
      MESSAGE I000(0K) WITH
        'DoubleClick' 'Upper Picture' POS_X POS_Y. "#EC NOTEXT
    else.
      MESSAGE I000(0K) WITH
        'DoubleClick' 'Lower Picture' POS_X POS_Y. "#EC NOTEXT
    endif.
  endmethod.

************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_context_menu
************************************************************************
  METHOD EVENT_HANDLER_CONTEXT_MENU.
    data menu type ref to cl_ctmenu.
    create object menu.
    call method menu->ADD_FUNCTION exporting
      fcode = text-001
      TEXT = TEXT-001.
    call method menu->ADD_FUNCTION exporting
      FCODE = TEXT-002
      TEXT = TEXT-002.
    call method menu->ADD_FUNCTION exporting
      FCODE = TEXT-003
      TEXT = TEXT-003.
    call method menu->ADD_FUNCTION exporting
      FCODE = TEXT-004
      TEXT = TEXT-004.
    call method menu->ADD_FUNCTION exporting
      FCODE = TEXT-005
      TEXT = TEXT-005.

    CALL METHOD SENDER->DISPLAY_CONTEXT_MENU
      EXPORTING CONTEXT_MENU = MENU.
  endmethod.

************************************************************************
* CLASS   c_event_receiver
* METHOD  event_handler_context_menu_sel
************************************************************************
  METHOD EVENT_HANDLER_CONTEXT_MENU_sel.
    DATA DISPLAY_MODE TYPE I.
    IF FCODE = TEXT-001.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL.
    ENDIF.
    IF FCODE = TEXT-002.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_STRETCH.
    ENDIF.
    IF FCODE = TEXT-003.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT.
    ENDIF.
    IF FCODE = TEXT-004.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_NORMAL_CENTER.
    ENDIF.
    IF FCODE = TEXT-005.
      DISPLAY_MODE = CL_GUI_PICTURE=>DISPLAY_MODE_FIT_CENTER.
    ENDIF.
    CALL METHOD SENDER->SET_DISPLAY_MODE
         EXPORTING DISPLAY_MODE = DISPLAY_MODE.

  endmethod.

endclass.

Reward all hepfull answers

Regards

Pavan

Former Member
0 Kudos

But ADS(Adobe Document Services) is a SAP software company (like SAP_BASIS for example?

Many thanks.

Luca

Former Member
0 Kudos

Hi OMkar,

but how does Adobe Form is linked to SAP?

Many thanks.

Luca

Former Member
0 Kudos

good..

tcode: SFP..

If u want to work on Adobe forms ,you need to install ADS(Adobe Document Services) and java stack in your system..

Check the report : SAPBC480_SOLUTION(Integration of PDF-Based

Forms Into ABAP Programs)

Check the form: BC480_solution.

Check the links

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d4fe7fca-0b01-0010-569a-9a9...

https://www.sdn.sap.com/irj/sdn/docs?rid=/webcontent/uuid/7c3bc67e-0c01-0010-dbb3-908315896909 [original link is broken] [original link is broken]

https://www.sdn.sap.com/irj/sdn/docs?rid=/webcontent/uuid/7c3bc67e-0c01-0010-dbb3-908315896909 [original link is broken] [original link is broken]

/people/vani.krishnamoorthy/blog/2006/05/17/fillable-adobe-forms-using-abap

regards,

Omkar.

Former Member
0 Kudos

Hi Shivshankar,

could you send me an example code, because I don't know so good how the smarforms run?

Many thanks,

Luca

Former Member
0 Kudos

Hi Luca,

These are steps for follow up.

CALL FUNCTION V_FM_NAME

EXPORTING

CONTROL_PARAMETERS = V_CONTROL_PARAMETERS

OUTPUT_OPTIONS = V_OUTPUT_OPTIONS

ORDER_NUMBER = IT_VBFA-VBELV

IMPORTING

DOCUMENT_OUTPUT_INFO = V_DOCUMENT_OUTPUT_INFO

JOB_OUTPUT_INFO = V_JOB_OUTPUT_INFO

JOB_V_OUTPUT_OPTIONS = v_JOB_V_OUTPUT_OPTIONS

****Take the raw data of smartform into one variable of same type as trfresult.

V_P_HTML = v_JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.

CLEAR V_HTML_XSTR . " Type xstring

LOOP AT V_P_HTML-CONTENT INTO V_HTML_RAW.

CONCATENATE V_HTML_XSTR V_HTML_RAW INTO V_HTML_XSTR IN BYTE MODE.

ENDLOOP.

V_HTML_XSTR = V_HTML_XSTR(V_P_HTML-LENGTH).

****Translating raw data into html data

CALL FUNCTION 'SCP_TRANSLATE_CHARS' "#EC NOTEXT

EXPORTING INBUFF = V_HTML_XSTR

INCODE = '4110'

CSUBST = 'X'

SUBSTC_SPACE = 'X'

IMPORTING OUTBUFF = V_HTML_STR

OUTUSED = V_HTML_LEN

EXCEPTIONS OTHERS = 1.

Now V_HTML_STR has data in string format. Now u can made changes in

this means, u can define ur image-url path in format of html tags.

and at the end of this u can append it to internal table.

Hope this will be most helpful for you.

Rewards the points,if it is helpful.

Regards

Shivshankar.

Former Member
0 Kudos

Hi Luca,

If you are printing data in html format from smartform, then it is possible that u can print data from URL.

Define the window size in smartform, give the code of html tag in ur driver programme.I am using the same.

Rewards the points if it is useful.

Regards,

Shivshankar.

Former Member
0 Kudos

Hi Omkaram,

but how does Adobe Form run? What I need to use Adobe Form?

I don't know what is Adobe Form. Is it a SAP tools?

Many thanks.

Luca

Former Member
0 Kudos

Hi Luca,

Adobe forms are advanced tool to design forms...

Advantages over Smart Forms/SAPscript

• PDF is a de-facto standard for forms in the Web

• Adobe LiveCycle Designer as an easy to use, flexible tool for designing

forms

• Adobe LiveCycle Designer is fully integrated into the SAP's IDEs: SAP

NetWeaver Development Studio (Java) and ABAP Workbench

• Graphics (BMP, JPEG, GIF, PNG, EXIF) can be included into forms directly

– no conversion required

• Objects (including texts) can be rotated

• Different page orientations (landscape, portrait) are possible within one form

• Graphical elements can be included in forms

• Forms can be created so that they conform to accessibility standards

• Complex layout elements can be shared between form developers

• Existing PDF or Word documents can be imported

• TrueType Fonts can be used; installation requires no upload

• Barcodes can be printed on all printers of types Postscript, PCL, PDF, or

Zebra

• Mailing and faxing is easier

• Forms are regular Repository objects with standard transport and versioning

• Interactive scenarios and integration into browser-based applications are

possible (Web Dynpro for Java or ABAP)

Regards,

OMkar.

Former Member
0 Kudos

Hi,

It is possible in Abode form.There you have option to give an URL for image in the layout editor of Adobe Live cycle designer.

Regards,

Omkar.

Former Member
0 Kudos

Hi Dave,

I don't want upload the picture in SAP with program RSTXLDMC, but I want print it immediadly from the URL.

Many thanks.

Luca

Former Member
0 Kudos

Hi Luca

Never had a reason to try this, but if you incorporate the HTTP_GET function method in your smartform you could download the picture from the URL and then upload using RSTXLDMC.

Let me know if this works, or if I have not understood the question correctly.

Good luck!

Dave

Former Member
0 Kudos

I think it is not possible in SAP R/3, as its not stored in SAP Database. May be its possible in some applications in enterprise portals.

Regards,

Vishal

Former Member
0 Kudos

Hi

Whatever picture we upload using the program RSTXLDMC is mostly the company LOGOs'

so if we print the Picture separatelt what is the use of that, unless it is there on the relavent document?

So the Picture(mostly company logos) should accompany the relative document and it should be in the paper on which some company data is there.

Reward points for useful Answers

Regards

Anji