Get GOS attachment list for notification via BAPI - abap

I need to find a BAPI (or a chain of BAPIs?) to read the Notification Attachment List (GOS) using as input the Notification number.
I've tried many BAPIs, but the only functional result was via SO_OBJECT_READ FM to which I passed Object ID (which I obtained from SOOD table).
Problem is that I'm unable to retrieve the attachment object list belonging to the notification.
Any idea or suggestion?

Try to use BDS_GOS_CONNECTIONS_GET function module to retrieve attachment list for notification. Specify parameters like this:
CALL FUNCTION 'BDS_GOS_CONNECTIONS_GET'
IMPORTING
logical_system = <system name> * << optional parameter
classname = BPR_NOTIF * << object type for notifications
objkey = 1014866112016 * << your notification number + year
client = XXX
TABLES
gos_connections = lt_attachments
.
The attachments links can be found in SRGBTBREL table and FM OBJKEY parameter corresponds to INSTID_A field of this table.

Related

Convert a spool into text format

I want to send the spool generated by a Smart Form, by email as attachment in TXT format.
The issue is to get the spool in a TXT format, without technical stuff, just the characters in the form.
I have used the function module RSPO_RETURN_SPOOLJOB for getting it, but it returns a technical format like this:
//XHPLJIIID 0700 00000+00000+
IN01ES_CA930_DEMO_3 FIRST
OPINCH12 P 144 240 1728020160000010000100001
IN02MAIN
MT0100808400
CP11000000E
FCCOURIER 120 00144 SF001SF001110000144E
UL +0000000000000
ST0201614Dear Customer,
MT0214209000
ST0864060We would like to take this opportunity to confirm the flight
MT0100809360
ST0763253reservations listed below. Thank you for your custom.
...
I want something as follows, without the technical stuff:
Dear Customer,
We would like to take this opportunity to confirm the flight
reservations listed below. Thank you for your custom.
...
This is the code I have used :
PARAMETERS spoolnum type TSP01-RQIDENT.
DATA spool_contents type soli_tab.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
exporting
rqident = spoolnum
tables
buffer = spool_contents
exceptions
others = 1.
If the parameter DESIRED_TYPE is not passed or has the value 'OTF', and the spool is of type SAPscript/Smart Form, the function module returns the technical format you have experienced.
Instead, you should use the parameter DESIRED_TYPE = 'RAW' so that all the technical stuff is interpreted and the form is returned as text, the way you request, as follows :
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
exporting
rqident = spoolnum
desired_type = 'RAW'
tables
buffer = spool_contents
exceptions
others = 1.

Create subobject programmatically, not in SLG0

When creating a new log object I want the subobject to be created on the fly if it doesn't exist yet.
This is what I have right now:
ls_log-object = mc_log_object.
ls_log-subobject = mv_log_subobject.
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = ls_log
IMPORTING
e_log_handle = mv_log_handle.
In order to avoid an error I check the object and subobject like this before:
CALL FUNCTION 'BAL_OBJECT_SUBOBJECT_CHECK'
EXPORTING
i_object = mc_log_object
i_subobject = mv_log_subobject
EXCEPTIONS
object_not_found = 1
subobject_not_found = 2
subobject_necessary = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 2.
mv_log_subobject = ''.
ENDCASE.
But I don't want to do it like this, I want to create a new subobject if it doesn't exist yet!
Is there some secret function call that can do this? :D
There is no secret function call or something similar. In fact SLG0 is nothing else than view cluster maintenance call (SM34). But I'm also wondering why you need this? If you need some more or dynamic differentiation of your logs you can you use field "extnumber" which you can set in your structure ls_log.
You can select in SLG1 with this field and also via log api.

How to handle Zim Error "The ZIM tree pool has overflowed"

I have the following code:
set output spoole
select * from displays where displayname='dsp020a'
select * from forms where formname in (select formname from displayforms where displayname='dsp020a')
select * from formfields where formname in (select formname from displayforms where displayname='dsp020a')
The third select is crashing ZIM with the following error:
*** ZIM System Error *** The Zim tree pool has overflowed. Type BYE to exit from Zim.
What am I doing wrong and how can I fix it?
When trying to use SQL in ZIM, I also saw problems and unexpected errors. You should always try to use the native ZIM 4GL commands to access data as well as object definitions.
ZIM Data Dictionary contains some predefined internal relations which can help analyse the data model. For example, you could say:
list all Displays DispDispForms DisplayForms where Displays.DisplayName = "dsp020a"
to find out which forms are contained in the given display. Likewise you could do:
list all Forms FormFormFields FormFields where Forms.FormName in ("f020a", "f020b", "f020c")
to list all form fields which belong to the given forms. Unfortunately, there is no relation between DisplayForms and Forms, so you cannot achieve directly what you tried in your example using SQL.
OR (added after your comment):
You can achieve that using a small program. For this example, it would be:
set output output_file
find Displays DispDispForms DisplayForms where Displays.DisplayName = "dsp020a"
while $setcount > 0
let vStr = DisplayForms.FormName
list all Forms FormFormFields FormFields where Forms.FormName = vStr
let $setcount = $setcount - 1
next
endwhile
set output terminal
Now you have all form fields which belong to all forms of the given display listed in the output_file.
There probably already is a relationship between dfs and forms in the db schema but the documentation is poor. However, you can create your own. Note that dfs is a role for displayforms.
add 1 rels let relname = 'dfsforms' relcondition = 'dfs.formname = forms.formname' reltype = 'ZIM' dirname = 'ZIM'
create rel dfsforms
Now you can find forms related to displays using:
find all displays dispdispforms dfs dfsforms forms formformformfields wh displays.displayname = 'dsp020a'

Sap Code Inspector - Generating a table of all PCodes linked to the classes

I have problems to read the error codes and corresponding messages of SCI message classes.
Is there an way to easy access those?
I'm using "Praxishandbuch SAP Code Inspector" as a reference, but in that regard it is of no help.
I looked in Se11 but the information to the messages isn't helpful.
Has someone an approch to build such a table?
You can try this, perhaps it will work for you. I use the code below to get the access to all the errors found by Code Inspector for particular user(s):
data: ref_inspec_a type ref to cl_ci_inspection.
ref_inspec_a = cl_ci_inspection=>get_ref(
p_user = pa_iuser
p_name = pa_inam
p_vers = pa_ivers ).
data: ls_resp type scir_resp,
lt_resp type scit_resp.
clear: ls_resp, lt_resp.
ls_resp-sign = 'I'.
ls_resp-option = 'EQ'.
ls_resp-low = pa_fuser.
insert ls_resp into table lt_resp.
call method ref_inspec_a->get_results
exporting
p_responsibl = lt_resp
exceptions
insp_not_yet_executed = 1
overflow = 2
others = 3.
Playing around with LT_RESP you can get results for more users at the same time.
After you execute the code above, you can check the attributes SCIRESTPS and SCIRESTHD of the object REF_INSPEC_A. These are the large tables, which contain the result data of the SCI check. You can either work with them on your own, or you can simply pass the object REF_INSPEC_A into the function module SCI_SHOW_RESULTS to get regular SCI user interface.
I found out that you can get all the changeable messages (found in SCI GoTo/Management Of/ Message Priorities) can be read from the scimessages attribute of the test classes.
With this help you can get about 60% of all errors.

Drupal 7 - How to check if a particular field has a value - sql query?

I'm trying to write a PHP code to validate a form input in a field. If the field has already value the system must send an error message. If there is not a value or the value is the same like the input then the form can be submitted.
The edited code is:
/**
* Implement a function to get the ID and the title of the referenced node
* of type Reservation
* by the nodereference field called Period
* in the currently edited node from type Board
* Try to do this by the node_load() instead of the database query
* Is it the correct method to get the edited node's ID?
**/
function period_get_value() {
$thisnodeboard = $node->field_period_1[$node->language][0]['nid'];
$reservationrec = node_load(array('nid'=>$thisnodeboard));
return $reservationrec->title;
}
/**
* Implement the hook_form_FORM_ID_alter function to validate
* if the field Period has already value set
* and if there is such to check if it is the same as the input value
**/
function period_validate_form_slickgrid_editor_form_alter(&$form, $form_state){
/**
* The current value is the title of the referenced node
**/
$valcurr = period_get_value();
$valnew = $form_state['values']['field_period_1'];
if (isset($valcurr)&&($valcurr!=$valnew)){
form_set_error('field_period_1', t('There is already value set for this field'));
}
return $form;
}
But it still doesn't work - does not set any message and allow for changing the existing value in the field_period_1.
Firstly, writing a manual SQL query in D7 is an absolute last resort.
OK so you actually want to just prevent the user from updating a field after the node has been created.
You can do one of two things. If you only want to prevent edits from the node/edit form you could implement hook_form_FORM_ID_alter() and then add your own validate or submit handler. You would then validate that the field has not changed and act accordingly.
If you wanted to prevent it happening from anywhere, Eg programmatically. You could implement hook_node_update() and check $node->is_new and $node->type to prevent changes to nodes that are not new.